Goldeneye Posted May 18, 2010 Share Posted May 18, 2010 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 https://forums.phpfreaks.com/topic/202211-explicitly-matching-strings-that-dont-span-multiple-lines/ Share on other sites More sharing options...
Goldeneye Posted May 19, 2010 Author Share Posted May 19, 2010 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 https://forums.phpfreaks.com/topic/202211-explicitly-matching-strings-that-dont-span-multiple-lines/#findComment-1060389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.