regular expression help

E

eagle_speaks

Hi,
I have the following data . From this I need to select the patern
matching

2.3.6 or 1.3.10 and nothing else.

-------------------
wedfsd
communicationsAlarm linkSetFailure -MMN:SSNC L989
2.3.6 signLinkTp
seffdLorgjh9890
------------------

I have tried various combinations but not getting much near

This expr
[([:digit:]\.[:digit:]\.[:digit:])*]*

is selecting this and everything else

so also is

\<[([:digit:]\.[:digit:]\.[:digit:])?]\>*

Can someone help me in in giving a expression which selects the pattern

digit.digit.digit

Thanks in advance
 
A

Aaron Sherman

eagle_speaks said:
2.3.6 or 1.3.10 and nothing else.

(2\.\3\.6|1\.3\.10)

You may or may not want a "\b" before and/or after that.
I have tried various combinations but not getting much near

This expr
[([:digit:]\.[:digit:]\.[:digit:])*]*

This is wrong, but I think I understand what you were trying to do.
First off, you said you wanted to match nothing but the above numbers.
Did you mean that you wanted to match any triplet of dot-separated
integers instead? That would be:

\d+\.\d+\.\d+

Again, with or without "\b" around it for requiring word-boundaries (to
avoid "Kernel2.6.17" for example).

Your mistakes above are:

1. POSIX named character ranges.

These cause untold problems for people because the nested brackets seem
to cause people's heads to fall out.

2. You are enclosing the entire match in brackets.

Your expression matches any number of the characters: "().0-9*" which
is decidedly not what you wanted.
 
T

Tad McClellan

Aaron Sherman said:
(2\.\3\.6|1\.3\.10)
^^
^^

There is no 3rd capture buffer to backref to...

.... and (after fixing that) it would match 2.3.1.3.10.

so you probably meant:

/(2\.3\.6)|(1\.3\.10)/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,808
Messages
2,569,686
Members
45,455
Latest member
GwendolynG

Latest Threads

Top