Link to home
Start Free TrialLog in
Avatar of tmajor99
tmajor99

asked on

Regular Expression to find a value "UL" and followed by a number (i.e., UL5 or UL 5).

I need help with a regular expression that will check a string for "UL" and followed by a number or a space and a number

Data                                                       Expected Result
---------------------------                              ---------------------------
UL 4                                                        True
ULXX                                                       False
UL7                                                         True
Z89                                                          False
UL/5                                                        False
Test UL5X                                              True
7UL                                                         False
8UL9                                                       True
UL-9999                                                  False
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India 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
I would use:
UL ?\d

Open in new window

It's possibly better to use a space character instead of \s, if the \s matching a tab or newline could give unexpected results.

If the number can be more than one digit, then you can add a + after the \d