B
B
BarneyGumble2018-08-06 15:00:25
Regular Expressions
BarneyGumble, 2018-08-06 15:00:25

How to write a regular expression to remove the end of a string?

There are articles like tr98000-TS, we98010-TS, etc. in the database (.sql file).
I need to remove everything after the hyphen along with it to end up with tr98000, we98000, etc.
If I make an expression for searching -TS , then important things like product1 -TS .jpg are deleted from the database.
How can I make an expression to find -TS exactly after any 2 alphabetic characters followed by 5 any digits?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick SDK, 2018-08-06
@BarneyGumble

How to compose an expression to find -TS exactly after any 2 alphabetic characters followed by 5 any digits?
https://regex101.com/r/GO1dm1/1

S
Saboteur, 2018-08-06
@saboteur_kiev

([a-zA-Z]{2,2}\d{5,5})-.*
https://regex101.com/r/GO1dm1/2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question