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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.