467,179 Members | 1,288 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

Using * works but using + doesn't work in matching MHI:;

100+
hey guys,

another question for thoughts,

i'm matching this:
Expand|Select|Wrap|Line Numbers
  1. MHI:;
  2.  
when i use
Expand|Select|Wrap|Line Numbers
  1. if($data1 =~ /^(\s\D\D\D:.+\;)/)
  2.  
it doesn't match

but when i use
Expand|Select|Wrap|Line Numbers
  1. if($data1 =~ /^(\s\D\D\D:.+\;)/)
  2.  
it matches

so why is it although i know "*" matches 0 or more times and "+" matches 1 or more times
May 16 '08 #1
  • viewed: 876
Share:
2 Replies
nithinpes
Expert 256MB
You have posted this in a hurry! (both RE you posted are same). Anyway, In the string:

Expand|Select|Wrap|Line Numbers
  1. MHI:;
  2.  
The colon(:) is immediately followed by semi-colon(;)
The RE in:
Expand|Select|Wrap|Line Numbers
  1. if($data1 =~ /^(\s\D\D\D:.+\;)/)
  2.  
will try to match atleast one character between ':' and ';' , that's why it fails and the RE in
Expand|Select|Wrap|Line Numbers
  1. if($data1 =~ /^(\s\D\D\D:.*\;)/)
  2.  
will work since it stands for 0 or more characters
May 16 '08 #2
100+
alright.thanks once again
May 16 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Erik Johnson | last post: by
7 posts views Thread by Vaca Louca | last post: by
5 posts views Thread by Michael Sperlle | last post: by
2 posts views Thread by Ole Nielsby | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.