dsaba Posted February 26, 2008 Share Posted February 26, 2008 haystack: I came up with this modeled after looking at a similar regex to match text not in html tags ( ~(?![^<]+>)\b(highlight|these|words|okay|text)\b~i ) (?!(??!/\*).)+\*/)//.*?\r\n The problem is it doesn't match the 2 single line comments at the bottom of the haystack. Any ideas how to fix this? Single line comments is // up until \r\n Multiline comments are /* up until */ Thanks for looking. *WOOPS - I have a pattern that does match correctly, i will reply with it in a couple moments, so this question is solved. Quote Link to comment Share on other sites More sharing options...
dsaba Posted February 26, 2008 Author Share Posted February 26, 2008 ~(?!(??!/\*).)+\*/)//.*?$~m Quote Link to comment Share on other sites More sharing options...
dsaba Posted February 26, 2008 Author Share Posted February 26, 2008 how do I match the literal '/*' that is not in between // and $ (end of line marker) ~/\*~ will match in //*/ i tried this: ~(?!(??!//)[^\r\n])*$)/\*~m but it won't match in /* alone it will only match in /*// or /* // Quote Link to comment Share on other sites More sharing options...
dsaba Posted February 27, 2008 Author Share Posted February 27, 2008 ~(?<!//.*)/\*~ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.