-1

I have a simple regex to grab a string, It works fine with words like HelloWorld without space and how can i grab a words with space or more than 1 word like Hello World

Text File

FAN PS-2 is NOT PRESENT  #like this 'NOT PRESENT'

Regex

Value FAN_PS (\S*) # regex

Start 
  ^FAN PS is ${FAN_PS_1}

What should I change in my regex so I can grab more than 1 word?

Thank you.

Nedy Suprianto
  • 201
  • 1
  • 6
  • 14

1 Answers1

0

You have to change your regular expressions. The current expressions \S* match a string of non-white-space characters, so it is normal that you only get the first word.

If you change \S* to [\S ]*, you will get multiple words. You can even change it to the simpler .* if you do not care about certain characters.

Read the python regex reference for information on different character classes.

Malte Hartwig
  • 4,477
  • 2
  • 14
  • 30