Forum Moderators: coopster

Message Too Old, No Replies

Regular Expression Question

How to reverse match literal string

         

lierduh

1:12 pm on Jul 23, 2005 (gmt 0)

10+ Year Member



I want to search for line breaks, but excluding certain ones. eg.

I want to search for

"abc\r\nABC" or "<abc>\r\n<ABC>"...

...but I do not want to include

"<ul>\r\n<li>" or "</li>\r\n<li>"

So what I need is to reverse match strings. A '^' in a character class only negates a single character, not a string. Any idea for me how to achieve this? Thanks.

killroy

2:55 pm on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



use look-forward and look-back:

([^\n\r]+)(?<!<li>¦</li>)\n\r([^\n\r]+)

this for example will get all strings which don't include \n or \r followed by "\n\r" followed by anothjer stirng not including \n or \r where the first string is NOT <li> or </li>

regards,
SN

lierduh

2:36 pm on Jul 25, 2005 (gmt 0)

10+ Year Member



Thanks killroy.:)