sarathi Posted August 3, 2009 Share Posted August 3, 2009 I am trying to replace a symbol if 'G' is not found before the character on the same line. I am trying to use this: ~(?<!G)({|}|,|\(|\))~ But this only works if 'G' is right before the character. How could I allow for space after the 'G'. Quote Link to comment https://forums.phpfreaks.com/topic/168573-replace-if-g-is-not-before-it-on-the-same-line/ Share on other sites More sharing options...
.josh Posted August 3, 2009 Share Posted August 3, 2009 Would help if you actually showed example content... Any reason why you can't use a negated character class? [^G]+ Quote Link to comment https://forums.phpfreaks.com/topic/168573-replace-if-g-is-not-before-it-on-the-same-line/#findComment-889214 Share on other sites More sharing options...
sarathi Posted August 3, 2009 Author Share Posted August 3, 2009 Well, say I have the string "hello name my Gname is name" I already have all instances of name turn blue with ~name~ >> <font color='blue'>name</font> but I want name to only be replaced if there are no G's before it on the same line. Quote Link to comment https://forums.phpfreaks.com/topic/168573-replace-if-g-is-not-before-it-on-the-same-line/#findComment-889221 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.