Please recommend a regular expression excluding return character

All-

Can anyone recommend a regular expression that excludes the return
character?

My objective is to find occurances of a string WITHIN A LINE of a text
file. Thus, if givein some_string1 and some_string2, match:

<some_string1><any_character/number/tab/forward-slash/etc_but_no_hard_return

<some_string2>

Thanks!

Kurt Euler

The ‘.’ doesn’t match newlines.

$ irb

“\n” =~ /./
=> nil
“\n” =~ /\n/
=> 0

···

On Wed, Dec 03, 2003 at 07:55:18AM +0900, Kurt Euler wrote:

All-

Can anyone recommend a regular expression that excludes the return
character?

My objective is to find occurances of a string WITHIN A LINE of a text
file. Thus, if givein some_string1 and some_string2, match:

<some_string1><any_character/number/tab/forward-slash/etc_but_no_hard_return

<some_string2>

Thanks!

Kurt Euler


Daniel Carrera | Top 100 things you don’t want the sysadmin to say…
PhD student. |
Math Dept. UMD | 84. Where’s the GUI on this thing?

“Kurt Euler” keuler@portal.com schrieb im Newsbeitrag
news:C47CCC6238EFD4119C5200508B95A10010B7F19D@cup1ex1.portal.com

All-

Can anyone recommend a regular expression that excludes the return
character?

My objective is to find occurances of a string WITHIN A LINE of a text
file. Thus, if givein some_string1 and some_string2, match:

<some_string1><any_character/number/tab/forward-slash/etc_but_no_hard_retu
rn

<some_string2>

Thanks!

Kurt Euler

If you use readline or gets you don’t even need to bother with the
newlines:

File.open(“file.txt”, “r”) do |f|
while ( line = f.gets )
line.chomp!

if /my_regexp/ =~ line
  puts "Found it!"
end

end
end

Otherwise omitting the /m flag at the regexp avoids “.” to match the
newline.

Regards

robert

In other words:

/#{some_string1}.#{some_string2}/

Cheers,
Daniel.

···

On Wed, Dec 03, 2003 at 07:57:55AM +0900, Daniel Carrera wrote:

The ‘.’ doesn’t match newlines.

$ irb

“\n” =~ /./
=> nil
“\n” =~ /\n/
=> 0

On Wed, Dec 03, 2003 at 07:55:18AM +0900, Kurt Euler wrote:

All-

Can anyone recommend a regular expression that excludes the return
character?

My objective is to find occurances of a string WITHIN A LINE of a text
file. Thus, if givein some_string1 and some_string2, match:

<some_string1><any_character/number/tab/forward-slash/etc_but_no_hard_return

<some_string2>

Thanks!

Kurt Euler


Daniel Carrera | Top 100 things you don’t want the sysadmin to say…
PhD student. |
Math Dept. UMD | 84. Where’s the GUI on this thing?


Daniel Carrera | Top 100 things you don’t want the sysadmin to say…
PhD student. |
Math Dept. UMD | 84. Where’s the GUI on this thing?