I want to able to search for multiple words on the same line.
For example, consider the file with the following contents:

....
11. 15 18 40 53 => 16 19 41 54
12. 03 15 27 64 => 04 15 28 65
13. 25 46 47 91 => 26 47 48 92
14. 10 15 32 53 => 11 16 33 54
15. 01 12 16 73 => 02 13 17 74
....

Say I want to search for occurrences of "15" or "53" or "92" on the same line. Then the correct lines that the search should identify are line 11 and 14. I don't want line 15 to be identified because the 15 is used as a numeral for the line, not as data. Also, I don't want the search to identify data to the right of the "=>" word, so the 15 on line 12 doesn't count either.

So what I want is a query for: find all occurrences of "15" or "53" or "92" that are found between "." and "=>". As a note, the numbers are increasing order, with no repetitions, on each line between the "." and "=>", so the search condition can be refined as: find the lines that have at least one of {15, 53, 92} between "." and "=>".

What I have so far is:

/[.].*\(15\).*\(53\).*\(92\).*\(=>\)

However, with this condition all three of "15", "53", "92" have to be on the same line.

Thanks.

> the 15 on line 12 doesn't count either.
There are two 15's on line 12.

You should probably post this in the Perl section.
I'd try (in Perl): /\..*\s(15|53|92)\s.*=>/

My mistake: the first 15 was supposed to be 14.

Thanks for your help.

/[.].*\(15\).*\(53\).*\(92\).*\(=>\)

This would still wouldn't give you the right answer? Its expecting all the search charcters to be in the same line. Look at nucleon post.

-ssharish

Actually, in vi all I need is:
/[.].*\(15\|53\|92).*[>]

I got confused because a website mentioned that to search for lines with 12 or 34, use "/\(12|34\)/".
However, it's missing a backslash in the group condition and it should have said to use "/\(12\|34\)/".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.