Regular Expressions

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
elitecodex
New php-forum User
New php-forum User
Posts: 67
Joined: Tue Jul 09, 2002 8:45 am
Location: East Coast, USA
Contact:

Tue Sep 03, 2002 11:24 am

I have a question. I thought that I understood regular expressions, but I guess I dont. Could anyone lend a helping hand?

I have this:

Code: Select all

preg_match("/([0-9]{2})([a-zA-Z])([0-9]{1,4})/i", $_POST["job_number"], $mat);
var_dump($mat);


and the input ($_POST["job_number"]) would be 02PR500 and I want to split that up. By "02" then "PR" then "500". Of course 02 and 500 could be any value between 1 and 9000. What am I doing wrong? Any help is greatly appreciated.

Will

elitecodex
New php-forum User
New php-forum User
Posts: 67
Joined: Tue Jul 09, 2002 8:45 am
Location: East Coast, USA
Contact:

Fri Sep 06, 2002 4:45 am

hello

I thank you for your response. I know have some questions though. If memory serves me right, then "^" and "$" match the beginning and end of a string, respectively. What does the "+" do?

Do you know where I could find some good docs on regular expressions? Im kinda new to them and want to start to really learn the fun stuff :)

Also, what the difference between perl regular expressions and regular expressions? I ask b/c I noticed that they both are supported in PHP and was wondering if they have a syntax difference or what.

Thanks for your response

Will

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests