473,387 Members | 1,569 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,387 software developers and data experts.

What does this reg expression mean?

Lyn
I'm trying to get my head around regular expressions while
maintaining some semblance of sanity. I'm canabalising a
similar program to construct my own, and it keeps using an
expression I'm not familiar with as a pattern matcher.

It looks like this:

([^"]*)

To me, it looks like 0 or more occurences of the beginning of
a string or quote character, but that doesn't make much sense
in the context it's used. And it's used multiple times, so
I'm hoping it's a widely used trick that someone might be able
to explain to me?

Cheers,
Lyn
Jul 19 '05 #1
5 4741
^ is the anchor here is a a good explanation on that

http://www.anaesthetist.com/mnm/perl/regex.htm

Lyn wrote:
I'm trying to get my head around regular expressions while
maintaining some semblance of sanity. I'm canabalising a
similar program to construct my own, and it keeps using an
expression I'm not familiar with as a pattern matcher. It looks like this: ([^"]*) To me, it looks like 0 or more occurences of the beginning of
a string or quote character, but that doesn't make much sense
in the context it's used. And it's used multiple times, so
I'm hoping it's a widely used trick that someone might be able
to explain to me? Cheers,
Lyn

Jul 19 '05 #2
Lyn wrote:
[...]
It looks like this:

([^"]*)

To me, it looks like 0 or more occurences of the beginning of
a string or quote character, but that doesn't make much sense
in the context it's used. And it's used multiple times, so
I'm hoping it's a widely used trick that someone might be able
to explain to me?


Inside of a character class the caret "^" looses it's special meaning and
does not match beginning of the string any more.
So this RE matches any sequence of consecutive carets and double quotes.

jue
Jul 19 '05 #3
In article <4%******************@nwrddc02.gnilink.net>,
ju******@hotmail.com says...
Lyn wrote:
[...]
It looks like this:

([^"]*)

To me, it looks like 0 or more occurences of the beginning of
a string or quote character, but that doesn't make much sense
in the context it's used. And it's used multiple times, so
I'm hoping it's a widely used trick that someone might be able
to explain to me?


Inside of a character class the caret "^" looses it's special meaning and
does not match beginning of the string any more.
So this RE matches any sequence of consecutive carets and double quotes.

jue

Jue,

Shame on you for this bit of misinformation!
From the "Regular Expression Pocket Reference" by Tony Stubblebine:

"Character classes are ways to define or specify a set of characters.
A character class matches one character in the input string that is
within the defined set.

Normal classes: [...] and [^...]
Character classes, [...], and negated character classes, [^...],
allow you to list the characters that you do or do not want to match.
(More info...)

So this RE, ([^"]*), captures zero or more occurrences of anything that
is not a double-quote. With the parentheses, there is capturing also
into a numbered variable, i.e., $1, $2 depending on how many previous
capturing parenthesis exist. Perhaps a better RE, in my mind, would be
([^"]+), i.e., one or more occurrences of anything not a double-quote.
The asterisk modifier would match zero or more of anything not a double-
quote which may or may not be what you want.

magoo
Jul 19 '05 #4
magoo wrote:
In article <4%******************@nwrddc02.gnilink.net>,
ju******@hotmail.com says...
Inside of a character class the caret "^" looses it's special
meaning and does not match beginning of the string any more.
[Wrong explanation snipped]
Shame on you for this bit of misinformation!
Ooops, you are right, of course
From the "Regular Expression Pocket Reference" by Tony Stubblebine:


However, does this book describe Perl REs or other REs?
I would rather check the Perl documentation because REs differ quite a bit
for different languages.

jue
Jul 19 '05 #5

"Jürgen Exner" <ju******@hotmail.com> wrote in message
news:hE******************@nwrddc02.gnilink.net...
magoo wrote:
In article <4%******************@nwrddc02.gnilink.net>,
ju******@hotmail.com says...
Inside of a character class the caret "^" looses it's special
meaning and does not match beginning of the string any more.

[Wrong explanation snipped]

Shame on you for this bit of misinformation!


Ooops, you are right, of course
From the "Regular Expression Pocket Reference" by Tony Stubblebine:


However, does this book describe Perl REs or other REs?
I would rather check the Perl documentation because REs differ quite a bit
for different languages.

jue


The book describes Perl RE's as well as others.
I don't have it in front of me, it is on my desk at work.
I just reached for the nearest reference I had at the time ;>)
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
22
by: Tony Johansson | last post by:
Hello Experts! I'm reading i a book about C++ and they mention infix with telling what it is. I hope you out there can do so. Many thanks! //Tony
3
by: RobertTG | last post by:
Someone please translate the code below into English... Particularly the indicated line Thanks function attachComment() { var aForms = document.getElementsByTagName("FORM"); for (var i = 0;...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
53
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
11
by: SGi | last post by:
I wonder if anyone here knew Pascal before C++, perhaps you could help me out. I'm converting some pascal code into C++, and I can't seem to understand what AType(Ptr) is trying to accomplish. ...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: lovecreatesbea... | last post by:
---quoting--- Annex C (informative) Sequence points 1 The following are the sequence points described in 5.1.2.3: - The end of a full expression: an initializer (6.7.8); the expression in an...
32
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.