How to detect regex pattern for strings with underscore?

Member

by mac , in category: Third Party Scripts , 4 months ago

How to detect regex pattern for strings with underscore?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lottie , 4 months ago

@mac 

To detect regex patterns for strings with underscore, you can use the following regular expression:

1
^.*_.*$


Explanation:

  • ^ : asserts position at start of the string
  • .* : matches any character (except for line terminators) zero or more times
  • _ : matches the underscore character
  • .* : matches any character (except for line terminators) zero or more times
  • $ : asserts position at the end of the string


This regex pattern will match any string that contains at least one underscore character.

Related Threads:

How to print matching strings in python with regex?
How to replace a substring with a regex pattern using regex in python?
How to get the list of replacement strings from a regex?
How to read first set of numbers between strings using regex?
How to handle strings that contain negative numbers using regex?
How to detect phone number on multiline using regex?