Jump to content

Easy Regular Expression Syntax Needed


ThePsion5

Recommended Posts

Hi guys,For anyone here that is familiar with regular expressions in PHP (which I am not, sadly), this should be fairly simple. I need the syntax for three expressions that will break a string apart explode()-style for the following strings:","", "";""; "I also need a regular expression for just the first two and last two characters. Unfortunately, however, I need this very soon and PHP's regular expression page intimidates me, lol. Is there anyone who can A.) show me the regular expressions I need or B.) point me towards a good tutorial that explain the basics of them without getting too involved. Thanks in advance!-Sean

Link to comment
Share on other sites

ok...I've done some researching and I think I found a regular expression formula that matches my first request. To break a string up by the following characters:,, + any number of spaces;; + any number of spacesI would use this expression:";*|,*"Is this anywhere near correct? :)

Link to comment
Share on other sites

Hm...that page was pretty helpful actually, thanks :)One other thing...the following regular expression give me an error, but I believe i'm using the correct syntax for it:

"*;*|*,*"

PHP tells me that "|" is an unknown modifier...according to the documentation, my version of PHP supports this as the 'or' character. What am I doing incorrectly?

Link to comment
Share on other sites

I figured it out...i misunderstood the '*' symbol to mean any character instead of just the preceding character, so it was using the first and last '*' as the delimiters and getting confused by the rest. This is the proper regular expression:"/ *; *| *, */"Maybe this will help someone else. :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...