how to match any character with ruby regexp?

N

Nanyang Zhan

It seems work well, but I'm not confident that the (.)* will safelly
match all the characters inside a <a> tag, for example, what if there is
a new line?
So, for ruby regex, which symbol can be surely used to represent any
character of a string? Thanks.
 
R

Robert Klemme

It seems work well, but I'm not confident that the (.)* will safelly
match all the characters inside a <a> tag, for example, what if there is
a new line?

irb(main):004:0> "a\nb".match(/.+/).to_a
=> ["a"]
irb(main):005:0> "a\nb".match(/.+/m).to_a
=> ["a\nb"]
So, for ruby regex, which symbol can be surely used to represent any
character of a string? Thanks.

A dot.

robert
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top