tags:

views:

35

answers:

1

Hi,

Will a regex created with the following terms match the same results?

"canon| eos" "1d"

and

canon|eos 1d

Now I do not want to match the quotation marks (") in the string. Will the fact they are in there make a difference.

Will the first term match "canon but not canon?

Am I right in what I am saying?

+4  A: 

These are two completely different expressions. What makes you think that they are the same?

The first expression will match either "canon or ␣eos"␣"1d".

The second expression will match canon or eos␣1d.

Konrad Rudolph
My point is that they are completely different expressions, it's what i've told a client. That their input file has incorrect expressions (because they do not want the quotation mark to be matched, yet they have included it). I needed a definite answer from somebody else as a "second opinion"
Dan Harris
Kondrad is right. If the two expressions you show are full regular expressions in themselves (ie not including any delimiters) then the first will match `"cannon` or ` eos" "1d"` (notice there is a space before `eos` also). The second will match `canon` or `eos 1d`
El Ronnoco