1

I have a files that shows the locale that the file is placed. So need to find when the file contains a certain locale and has a certain word in it.The word maybe anywhere on the page.

Regex

/^.*?\b(uk_en)\b.*?\bneedle\b.*?$/m

Example

id: page_name
locale: uk_en
----
<div> placeholder placeholder  placeholder placeholder placeholder placeholder</div>
<span>placeholder placeholder placeholder placeholder placeholder placeholder  </span>
<p>Needle</p>

My reference for the regex Regular expression to find two strings anywhere in input

Link to test https://regex101.com/r/dFdQl3/1

Community
  • 1
  • 1
puppet
  • 88
  • 1
  • 10

1 Answers1

1

You don't really need the multiline flag. What you instead need is the single line flag. Also note that your regex contains needle but your string contains Needle, so you need the insensitive flag as well.

/\b(uk_en)\b.*?\bneedle\b/si

Live preview

vallentin
  • 23,478
  • 6
  • 59
  • 81