Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS selector regex match start and end

let say I have elements with title attribute like following

<div title="custom-marker-awlr-tailrace bbu-l2"></div>
<div title="custom-marker-aws-tailrace btut"></div>
<div title="custom-marker-arr-tailrace sbu-l3"></div>
<div title="custom-marker-wqs-tailrace bbu-l2"></div>
<div title="custom-marker-wqs-tailrace bbu-l1"></div>

how do I select div with title custom-marker-wqs-tailrace bbu-l2 using CSS regex selector?

something like div[title*="customer-marker-wqs...???"] I don’t know what should I write in place of ???

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You may use a single attribute selector, e.g.

div[title="custom-marker-wqs-tailrace bbu-l2"] {
  ...
}

so you match the exact string or you could chain two attribute selectors, e.g.

div[title^="custom-marker-wqs-tailrace"][title$="bbu-l2"] {
   ...
}

by selecting a title starting (^=) with custom-marker-wqs-tailrace and ending ($=) with bbu-l2

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading