Regex Missing out 1 special character

Hi I am using this regex pattern “(?<=Module Name:\s)[A-Z]*[#|++|-]?”, Why can;t my condition retrieve 2 ++ at once? I have a module Name that is called C++. When i ran this i only got C+, I can;t seem to retrieve ++ together, I need it to get C++

Hi @Jovian_low,

(?<=Module Name:\s)[A-Z]*(#|\++|-)
Here all the parameters like #,+,- has to be enclosed within parantheses and not in square brackets. Because latter will treat them as single character while matching.
For testing either regex101.com or regexr.com can be used that describes what we do.

Regards,
Dominic

Hello @Jovian_Low,

Try this solution with the next pattern and let me know.

(?<=Module Name:)((.*\n)?)(?=Module Code)

Regards,
Susana

1 Like

hi @Susana I tried the code you gave me it doesn;t work, am I suppose to add anything else beside the code you gave me? Sorry I am really new to regex…

Hi @Jovian_Low,

It is working for me. This attachment
TestExtractTextBetweenLabels.zip (2.2 KB) contains a txt file with the text:

Module Name: ENTREPRENEURSHIP
Module Code:BM0515
Module Name: PRINCIPLES OF ACCOUNTING
Module Code:BM0031
Module Name: COMMUNICATION SKILLS 2
Module Code:IT2565
Module Name: CYBER SECURITY TECHNOLOGY, LAW AND ETHICS
Module Code:IT1528

The ouput for the example .xaml is

  • ENTREPRENEURSHIP
  • PRINCIPLES OF ACCOUNTING
  • COMMUNICATION SKILLS 2
  • CYBER SECURITY TECHNOLOGY, LAW AND ETHICS

Is this right?

Best Regards,
Susana

1 Like

@Susana Hi the output is right but its not working for my workflow i get empty results.SyllabusRetrieval.xaml (16.3 KB)

Hello @Jovian_Low,
I had not seen your answer, sorry. It is already works? If not, can you share your files to check them? I can not reproduce your problem.
Regards,
Susana

@Susana Hey thanks for replying it is working already, thanks for asking!