Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Re: Regular expression to find strings prefixed with odd number of a hash(#)

  •  01-27-2009, 5:56 PM

    Re: Regular expression to find strings prefixed with odd number of a hash(#)

    Try:

    (?<!#)(?>(##)*)#[^#]+

    or

    (?<!#)(##)*#[^#]+ 

    You can add whatever other criteria are necessary to find the end of the match.

    BTW, the reason you don't match "#param1" is that your lookbehind requires at least 1 match of the '(##)' sub-pattern. However if you change the '+' to '*' on its own, then you can get incorrect matches such as "####param1" which will simply ignore the first # and match the next 3.

    Susan 

View Complete Thread