Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
spacebiscuit
Forum Contributor
Posts: 390 Joined: Mon Mar 07, 2005 3:20 pm
Post
by spacebiscuit » Wed Dec 14, 2005 7:31 am
Hi,
I am trying to extract the date from a string with this regular expression:
The problem is that part of the string is the forward slash '/' which is also the string delimiter (?). How do I search on this charcter without causing the error:
Unknown modifier '\'
Thanks in advance.....
Rob.
Skittlewidth
Forum Contributor
Posts: 389 Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK
Post
by Skittlewidth » Wed Dec 14, 2005 8:49 am
I'm no expert on Regex but I think part of your problem is this:
should be
as "\d" is any single digit and \d{2} would be two digits.
You just have the wrong slashes.
How are you applying this to your string though? You may be implementing it slightly wrong as well.
Edit: agh! Stupid PHPBB stripped the backslashes from my original code example! (fixed by putting it in Code tags instead of PHP)
Last edited by
Skittlewidth on Wed Dec 14, 2005 9:35 am, edited 3 times in total.
sheila
Forum Commoner
Posts: 98 Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas
Post
by sheila » Wed Dec 14, 2005 9:29 am
From "Regex CRASH Course! (Pt. 1)"
viewtopic.php?t=33147
To delimit a regex we start and end with the EXACT same character. The two standards are (but you can use most non-alphanumeric characters):
Code:
/pattern/
#pattern#