Home > Blockchain >  Regex to pick all occurrences of certain word
Regex to pick all occurrences of certain word

Time:08-20

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;

CodePudding user response:

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.)

  • Related