user3319283
user3319283

Reputation: 11

Extracting a string from regular expression

Using regular expressions, I want to extract the name2 from name1_99_name2.sql

Using this:

\_[a-z]+  

I extract name2 with the underscore before, but I need it without it.

Any idea?

Upvotes: 1

Views: 65

Answers (1)

Nyx
Nyx

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

Related Questions