Please could someone help me, i will be forever appreciative.
I’m trying to create a regular expression which will extract 797 from “Your job 797 (“job_name”) has been submitted”
or “Your Job 9212 (“another_job_name”) has been submitted” etc.
Any ideas? Thanks guys!
Are there any special conditions about grabbing the number?
To grab the first number, just use
/\d+/withpreg_match.Otherwise you could do something like the following which searches for a number preceeded by “job” (case-insensitive).
(There are better alternatves for this regex, but best to keep things simple at first.)
Another option would be to move away from regular expressions into more basic parsing of a string:
Of course, similar could be done with
preg_matchbut it’s good to offer alternatives.