russy Posted June 18, 2008 Share Posted June 18, 2008 I'm making a script that uses BBtags. I'll do my best to explain my problem. Lets say we have a user named: bob[hi]yay\ If you have that username, in a lot of forums it tends to cause a problem, such as: yay\]test Basically I want to have it so you can escape the [ ] and \ characters, and regular expression will pick up on whats escaped and whats not. I have a basic understanding of regular expressions, and heres my older code that ignores escaping characters: $parse['data'] = preg_replace("{\[{$bbtag['tag']}=(.+?)\](.+?)\[/{$bbtag['tag']}\]}sei", "\$this->bbtag({$bbtag['id']}, '\\2', '\\1')", $parse['data']); The thing is it has to ignore a \], however NOT ignore a \\] which is the problem for me. Any help would be great, thank you. Link to comment https://forums.phpfreaks.com/topic/110701-escaping-bbtags/ Share on other sites More sharing options...
effigy Posted June 18, 2008 Share Posted June 18, 2008 - Why are brackets valid in the first place? - Are you saying that "bob[hi]yay\" is going to be inserted into the database as "bob\[hi\]yay\", thus allowing you to ignore the brackets? - Depending on the number of tags you have, you can disallow invalid tags. Link to comment https://forums.phpfreaks.com/topic/110701-escaping-bbtags/#findComment-568182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.