AbuMariam
AbuMariam

Reputation: 3678

Why is this regular expression not matching?

Could someone tell me why this regular expression does not match the below string? How could the regex be tweaked so it could match? The strings '470123023' and '11-03-2015' need to be in the regex...

.*-11-03-2015-.*_470123023_.*_META\.xml

wehansen-11-03-2015-09-35-12_470123023_META.xml

Upvotes: 3

Views: 57

Answers (2)

Perfect28
Perfect28

Reputation: 11317

It's not matching because it needs at least two underscore _ (just before META)

.*-11-03-2015-.*_470123023_.*_META\.xml
                          ^  ^
                          |  |
                         here is the issue

You should replace this

 .... 3_.*_META ....

with something like

 .... 3.*_META ....

Upvotes: 5

anubhava
anubhava

Reputation: 785128

You have extra underscore and .* before META, try this regex:

.*-11-03-2015-.*_470123023_META\.xml

RegEx Demo

Upvotes: 2

Related Questions