How to find a character in a string

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

How to find a character in a string

#1 Post by batnoob » 31 Jan 2018 10:54

I would like to search the value of a variable for a certain character (a period)
I tried findstr and jrepl, but all i got was errors (maybe I used the syntax wrong?). Could anyone help me?
Thanks,
BatNoob

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: How to find a character in a string

#2 Post by ShadowThief » 31 Jan 2018 13:05

Do you just want to know if the string contains that character, or do you need to know exactly where in the string it is? Those are two very, very different solutions.

batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

Re: How to find a character in a string

#3 Post by batnoob » 02 Feb 2018 12:01

i need to know if it is in the string

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: How to find a character in a string

#4 Post by Squashman » 02 Feb 2018 12:29

Code: Select all

IF NOT "%string:.=%"=="%string%" echo character found

batnoob
Posts: 56
Joined: 19 Apr 2017 12:23

Re: How to find a character in a string

#5 Post by batnoob » 02 Feb 2018 12:54

thank you, that is just what I needed.

Post Reply