Skip to content
Advertisement

Regex to capture #Facilitator:”Full Name ” tags

Please help with the regex, the language can be any. I’ll later translate it to python.

I’m trying to build a regex to capture the tag below:

JavaScript
  • Full name can be with accents like José, Pâmela, or any available in the ASCII table.
  • Full name can have 1, 2 or n family names. Could have or not a ‘(comapny name)’ at the end of the name: like #Facilitator:"Name1 Name2 Name3 (Company Inc) <mail@domain>"
  • The tag can appear 0, 1 or n times in strings.
  • The tag can appear in any place of the string.

So far trying like this (python) but no success:

JavaScript

The output i expect is a list of 0, 1 or more #tags separated by a space.

Any help on any language? I need help mostly with the regex itself. thanks so much.

Advertisement

Answer

You can find all the facilitators using re.findall with this regex:

JavaScript

e.g.

JavaScript

For your sample data this gives

JavaScript

You could then use str.join to make a space-separated list:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement