beasone
beasone

Reputation: 1085

regex how to find filename which doesn't contain any numbers?

I tried with [^0-9].* and [^\d].* But none of them is working: enter image description here

I only want to get filename which doesn't contain any numbers, in above case, I need to get BUILDING.txt.

I also tried with enter image description here But it only matches the characters instead of the whole filename.

Here is the online tool: https://www.regextester.com/

Tried with remove .

enter image description here

Upvotes: 1

Views: 432

Answers (4)

Kamuffel
Kamuffel

Reputation: 642

The following regular expression should do the job. Since you've requested to only capture the filename of a file not containing numbers (this means only the filename and not the extension of the file).

^([a-zA-Z]+)(?=\.[a-zA-Z])

You can test the above regular expression here:

https://rubular.com/r/NMcMicEmLUKNTB

Upvotes: 1

Code Maniac
Code Maniac

Reputation: 37775

You can simply use

^[^\d]+$

enter image description here

Demo

Upvotes: 2

Frank Levasseur
Frank Levasseur

Reputation: 101

try:

/^(\D*)$/gm

Hope it helps

François

Upvotes: 2

Emma
Emma

Reputation: 27743

My guess is that you might be trying to design an expression similar to:

^(?!.*\d).*$

The expression is explained on the top right panel of this demo, if you wish to explore/simplify/modify it, and in this link, you can watch how it would match against some sample inputs step by step, if you like.

Upvotes: 4

Related Questions