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

Regex to pick all occurrences of certain word

i want to pick every __custom_field:something on this string

${__active_activity_report/__custom_field:matrix_on_list/__custom_field:matrix_integer}

my best attempt was (\/.*?(custom_field).*\/|) but im failling to catch the case where it doesnt end with a / but with a } , i tried or cases but i might be doing it wrong;

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 can use

/__custom_field:\w+/g
/_+custom_field:\w+/g

See the regex demo.

Details:

  • __custom_field: – a fixed string
  • \w+ – one or more letters/digits/underscores.

The _+ part matches one or more underscores (in case you have _custom, __custom, ___custom, etc.)

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