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 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 ? 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. 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) 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 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. 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. 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... 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. 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.. ^^ 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
Archived
This topic is now archived and is closed to further replies.