Reputation: 11
Using regular expressions, I want to extract the name2 from name1_99_name2.sql
name1
: any sequence of characters99
: any sequence of numbersname2
: any sequence of charactersUsing this:
\_[a-z]+
I extract name2
with the underscore before, but I need it without it.
Any idea?
Upvotes: 1
Views: 65
Reputation: 425
[^_]+(?=\.sql$)
If your string always ends with ".sql".
But as Hayk pointed out, maybe you don't really need a regex here as a simple string manipulation function could do the job.
Upvotes: 1