The Reverend Posted August 3, 2006 Share Posted August 3, 2006 Thank you justsomeguy for explaining that, I probably should have in the first place. It's extremely easy to use, and it's not to hard to add new codes to if you follow the formatting carefully. This particular one is fairly customized for my own use. If you need to add tags it's fairly simple.start out with "/"Then I assume you're gonna have some kind of tag like this [r], simply escape the brackets\[r\]add the (.*?) in the middle, this is the wildcard.then close the tag the same way it's opened, but you have to escape the / as well\[\/r\]then simply end it with /isthe end result being'/\[r\](.*?)\[\/r\]/is'Hope this helps, this function has been a lifesaver for me.btw, if you didn't notice, this function will also convert \n to<br /> Link to comment Share on other sites More sharing options...
boen_robot Posted August 3, 2006 Share Posted August 3, 2006 OK. I don't know regular expressions enough to know that, so what's the "/is" for? I've also noticed the last expression ends with /i instead. What's this indicating? case (in)sencetivity? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 3, 2006 Share Posted August 3, 2006 That's right, i is case-insensitivity, and s is non-greedy. If you have something like this:<div>this is the first div</div> <div>this is the second div</div>You can have a pattern that find everything between <div> and </div>. If you do not include the s modifier, the regular expression engine will default to greedy behavior, and it will match all of this:this is the first div</div> <div>this is the second divGreedy means that it will get as much as possible to still satisfy the pattern. If the s modifier is used, the pattern is non-greedy and it will find as little as possible to satisfy the pattern, so it will match the first div, and then the second one. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now