Just Me
Just Me

Reputation: 1053

Regex: Select links containing space

I want to find all links containing a space before extension .html

bla blah THIS-IS-MY-LINK .html blah blah

I made a regex, but is not quite good, because it selects everything before my link, not just my link:

.*(\w+( .html))

Can anyone help me a little bit?

Upvotes: 1

Views: 31

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626794

Assuming there must be a regular space between 1+ non-whitespace characters and a .html, you may use

\S+ \.html

Details:

  • \S+ - 1 or more chars other than whitespace
  • - a space (if you may have any whitespace here, replace with \s, and if there can be any horizontal whitespace, replace with \h)
  • \.html - a .html substring. enter image description here

Upvotes: 1

Related Questions