473,396 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

170 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
2 1011
nithinpes
410 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
poolboi
170 100+
alright.thanks once again
May 16 '08 #3

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

Similar topics

4
by: Erik Johnson | last post by:
I am still fairly new to Python and trying to learn to put RE's to good use. I am a little confused about the finditer() method. It is documented like so: finditer( pattern, string) Return an...
5
by: Henry | last post by:
I have this simple code, string escaped = Regex.Escape( @"`~!@#$%^&*()_=+{}\|;:',<.>/?" + "\"" ); string input = @"a&+" + "\"" + @"@(-d)\e"; Regex re = new Regex( string.Format(@"(+)", escaped),...
7
by: Vaca Louca | last post by:
Hello, My setup: Debian sarge on dual Pentium 4. g++ 3.3.5-3. (the other system is Windows XP with MS Visual Studio .NET 2003) I have an auto_array<T> template (based on a template taken from...
11
by: rajarao | last post by:
hi I want to remove the content embedded in <script> and </script> tags submitted via text box. My java script should remove the content embedded between <script> and </script> tag. my current...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
2
by: Ole Nielsby | last post by:
First, bear with my xpost. This goes to comp.lang.c++ comp.lang.functional with follow-up to comp.lang.c++ - I want to discuss an aspect of using C++ to implement a functional language, and...
1
by: LoopyNZ | last post by:
Hi there, I have an IIF expression that is returning a 0 (exact match), 1 (partial match), or 2 (no match) based on comparing text fields (see below). However, when I try to sort the results...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.