Hello,
i have a text and want to find all occurences of: prefix RM-EC + 3 digit number. For example RM-EC001, RM-EC099 or RM-EC100. But RM-EC99 should not be found.
Thank you.
Hello,
i have a text and want to find all occurences of: prefix RM-EC + 3 digit number. For example RM-EC001, RM-EC099 or RM-EC100. But RM-EC99 should not be found.
Thank you.
Try this:
RM\-EC\d{3}
As you're using SQL Server, I just found you can't to use quantifiers:
CREATE TABLE #test (value varchar(10))
INSERT INTO #test VALUES ('RM-EC001')
INSERT INTO #test VALUES ('RM-EC099')
INSERT INTO #test VALUES ('RM-EC100')
INSERT INTO #test VALUES ('RM-EC99' )
SELECT * FROM #test WHERE value LIKE 'RM-EC[0-9][0-9][0-9]'
The regular expression should look like this:
RM-EC[0-9]{3}
Depending on the regular expression implementation, you could also use \d
instead of [0-9]
.
I know you asked for a RegEx, but since you also tagged the question as SQL Server, I'll point out that this would also work:
WHERE YourColumn LIKE 'RM-EC[0-9][0-9][0-9]'