Jump to content

Explicitly matching strings that don`t span multiple lines


Goldeneye

Recommended Posts

What would I use to explicitly match strings that do not span multiple lines?

 

I thought, (.\S?) (instead of the less partial (.*?)) would do accomplish what I want, but it doesn`t. I`ve also searched around (this forum included) but haven`t found anything relevant which leads me to believe that I might be over-thinking this.

Okay, I have figured out what I was doing wrong, and as embarrassing as this is... I should've been using (\S*?) instead of (.*?). I was simply replacing the wrong character with the \S. This hit me when I realized that periods (.) tell the regex to match any character except for a linebreak. My regular expression does appear to be working now.

 

So, if you want a sub-class to match anything up to a linebreak, tab, space, or return; use: (\S*?).

 

It should be noted that \S symbolizes non-whitespace characters

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.