Azu Posted November 14, 2007 Share Posted November 14, 2007 Hello.. I am trying to get my regex to only work if the beginning or ending is not a certain character. The problem is that when I try to do this, and it is not that character, it deletes that character.. Is there a way to make it just CHECK if something is true, instead of deleting it and putting it into a regex variable? '[^"<>]Stuff[^"<>]'/i Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/ Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 some code your using would be helpful are you using preg_replace ? Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391293 Share on other sites More sharing options...
Azu Posted November 14, 2007 Author Share Posted November 14, 2007 Yes. Although it should work with any regex function so I didn't know it mattered, sorry. Here is the code '[^"<>]Stuff[^"<>]'/i These [^"<>] are deleting a character how do I stop this? I want these to read only, not modify the string in any way at all. Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391299 Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 if you give me an example maybe I could help I don't know what you want to do with this regexp (Sorry a little slow today) Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391305 Share on other sites More sharing options...
Azu Posted November 14, 2007 Author Share Posted November 14, 2007 I am trying to get my regex to only work if the beginning or ending is not a certain character. Here is an example '[^"<>]Stuff[^"<>]'/i Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391318 Share on other sites More sharing options...
effigy Posted November 14, 2007 Share Posted November 14, 2007 Here is an example '[^"<>]Stuff[^"<>]'/i That's a pattern--not an example. Try lookarounds. Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391444 Share on other sites More sharing options...
Azu Posted November 14, 2007 Author Share Posted November 14, 2007 Thank you that is exactly what I was looking for BTW here's an example; I only want to match something that isn't in quotes or braces. Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391451 Share on other sites More sharing options...
Azu Posted November 14, 2007 Author Share Posted November 14, 2007 Nevermind it's not working at all.. even when I tell it to return false if there is ANY character before or after it, it STILL goes through.. (?<!.)Stuff(?!.) x_x please help... Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391457 Share on other sites More sharing options...
effigy Posted November 14, 2007 Share Posted November 14, 2007 Please post your code which shows: 1. The input data. 2. The code parsing this data. 3. The (incorrect) result, and the result that is desired. Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391458 Share on other sites More sharing options...
Azu Posted November 14, 2007 Author Share Posted November 14, 2007 Ugh I'm sorry nevermind. I edited the wrong file lol Working perfect now. I should go to bed now, good night.. ^^ Quote Link to comment https://forums.phpfreaks.com/topic/77287-solved-doesnt-begin-or-end-with-these-characters/#findComment-391463 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.