HelloWorld1
HelloWorld1

Reputation: 14108

Customized Regex Code with Character

Goal:
The first letter shall be a small or a big character only and after that, the data ":\\" is should follow along. Data ":\\" is static.

Problem:
I have problem with my regex code.

^[a-zA-Z]:*$

Info:

C:\\dd\\sd\\faf.txt      true
c:\\ss\\dw\\fbf.txt      true
D:\\ff\\d3\\fcf.txt      true
d:\\da\\ds\\Df\\ff.txt   true
2:\\ad\\dd\\ff           false
2:\ad\\dd\\ff            false
d:\da\\ds\\Df\\ff.txt    false
c\\ss\\dw\\fbf.txt       false
D:\da\\ds\\Df\\ff.txt    false

Upvotes: 1

Views: 49

Answers (3)

Ali Nikneshan
Ali Nikneshan

Reputation: 3502

You need to detect correct PATH format in Windows.
Using this pattern can help: ^[a-zA-Z]:(\\\\[^\\]+)*
You can check my sample. Also note I add one more test to it:

D:\\da\\ds\Df\\ff.txt    false

Upvotes: 1

Steve Wellens
Steve Wellens

Reputation: 20620

Look what Expresso can do for you:

enter image description here

Upvotes: 0

inic
inic

Reputation: 522

Close your missing a .* after the : Below should work.

^[a-zA-Z]:.*$ 

Upvotes: 0

Related Questions