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. Link to comment https://forums.phpfreaks.com/topic/93160-match-single-line-comments-not-existing-within-multiline-comments/ Share on other sites More sharing options...
dsaba Posted February 26, 2008 Author Share Posted February 26, 2008 ~(?!(??!/\*).)+\*/)//.*?$~m Link to comment https://forums.phpfreaks.com/topic/93160-match-single-line-comments-not-existing-within-multiline-comments/#findComment-477290 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 /* // Link to comment https://forums.phpfreaks.com/topic/93160-match-single-line-comments-not-existing-within-multiline-comments/#findComment-477320 Share on other sites More sharing options...
dsaba Posted February 27, 2008 Author Share Posted February 27, 2008 ~(?<!//.*)/\*~ Link to comment https://forums.phpfreaks.com/topic/93160-match-single-line-comments-not-existing-within-multiline-comments/#findComment-477643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.