N
N
Nikita2019-07-06 19:04:11
cmd/bat
Nikita, 2019-07-06 19:04:11

Regular expression in .BAT, how to write it correctly?

Hello! There was a need to use a batch file, I thought I would throw in the regular expression that I use in a regular notebook - but it refuses to work in a batch file.
Here is the regular season itself: (^.*:.*)(2000)(.*$)
Please, please help! Perhaps it needs to be modified in some way? I've been in this business for just a couple of days, I'm just still learning.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Armenian Radio, 2019-07-06
@gbg

No way. CMD does not support regular expressions

E
Eugene, 2019-07-06
@yellowmew

Armenian Radio is partly right: you won't be able to use your regular expression in cmd scripts.
Exit 2:
1. rewrite the regular expression to use command-line tools
such as findstr or for
However, I don’t know how to work with groups in findstr and I don’t even know if it can group
for / f groups can, but it’s limited and you can support two types of regular expressions necessary?
2. use powershell https :
//docs.microsoft.com/en-us/powershell/module...
in the described document)

R
res2001, 2019-07-07
@res2001

I'll add my 5 kopecks to the answers:
The text of your regular expression contains special cmd characters that need to be escaped.
Specialist. characters in your case are characters: ^()
Escaped with a character ^
This set of spec. cmd characters are not exhausted and escaping is not always the same as in this case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question