Reputation: 18108
is it possible to create a OR condition in a regular expression.
i am trying to locate a match that contains a list of file names of this type of pattern
1st case
xxxxx-hello.file
or 2nd case
xxxx-hello-unasigned.file
this reg > -hello.file
works fine for the first case but is their a way to check the second case too?
i do not want to create two regex and want to combine the two cases if possible.
Thanks.
Upvotes: 0
Views: 94
Reputation: 18108
I fixed this myself using multiple include in a fileset.
this did the trick for me. no idea why the reg ex diddnt work.
<fileset dir="bin" >
<include name="welcome-hello-unasigned.file" />
<include name="welcome-hello.file" />
</fileset>
Upvotes: 0
Reputation: 219938
Make the group optional:
.*-hello(-unasigned)?[.]file
If performance is an issue, you should set that group as a non-capturing group:
.*-hello(?:-unasigned)?[.]file
If you want it to only match that exact amount of characters, you should use a pipe for your OR case:
.{5}-hello[.]file|.{4}-hello-unasigned[.]file
Upvotes: 7