Link to home
Start Free TrialLog in
Avatar of tmajor99
tmajor99

asked on

Regular Expression - Check for word in a string

I need a regular expression to check for a word in a string that has a "/".  

Value
---------
40005 Btu/h    ---->  I need to detect if the value has "Btu/h"
5009 BTU/H    ---->  I need to detect if the value has "BTU/H"
6999 BTU        -----> I also need to detect if value has just "BTU".
6700
900000 Btu
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Try pattern:
btu(\/h)?

Open in new window

with the case insensitive option active.

Demo:
https://regex101.com/r/jddy9t/1
Or did you specifically want the given combinations of upper/lower case?
Avatar of tmajor99
tmajor99

ASKER

Yes, this needs to be case sensitive.  Also, this did not work.  I need an expression that would cover all the scenarios listed below.

Value
---------
40005 Btu/h    ---->  I need to detect if the value has "Btu/h"
5009 BTU/H    ---->  I need to detect if the value has "BTU/H"
6999 BTU        -----> I also need to detect if value has just "BTU".
6700
900000 Btu
ASKER CERTIFIED SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial