How to check if the string contains two characters/alphabets or not

Hi All,

I want to check if my strings contains a “+” sign and two characters/alphabets or not.

string can be like this :- ‘26 | 32’!F8+‘26 | 32’!F12

Here the condition satisfies like it contains a “+” sign and two F’s . Like this I have to check others strings too. How should I achieve this?

Please help

1 Like

Hello @Karan28,

Use if condition like this, StrVar.Contains(“+”) and StrVar.Contains(“F”)

Cheers
@Karan28

StrVar.Contains(“F”) - This cant be because it should be dynamic and any characters can come so I have to check two characters/alphabets present or not . It can be between A-Z

1 Like

Okay so you want to check aplhabets in the string right??

You can use IsMatches Activity and Pass the Pattern Like this [A-Za-z]+ this will return boolean value if your string contains any Alphabets it’ll throw you True message

as you can see, i’ve used sample expression to identify only alphabets!

Give a try and let me know!

Cheers
@Karan28

2 Likes

@Karan28, you should mark this as a solution.
I have checked it out and it works.

Cheers,
Dino

1 Like

Hey , I want to check if it contains more than one alphabet of not. Not just alphabet

1 Like

It’s gonna work

Cheers

1 Like

Hi Yes I got your solution , But I have to get true only if it have two or more than two alphabets.

It should return false in one alphabet

1 Like

so if string contains more than two Alphabets it should return false?

It should return false with one Alphabet.

it should return true with two or more than two alphabets

1 Like

Sure, Do this

then use if condition like Cint(outMatches.Count)>=2

Cheers
@Karan28

Thats an amazing solution , much thanks.

Can I count how many + or - signs contains in string . For example in the above string it contains one + sign. Can I count this too

1 Like

yes, just pass this as pattern “\+” and use same method as i mentioned above

Cheers
@Karan28

Thats amazing , I will mark it a solution . Like I have to check how many + or - it should contains.

As you mentioned it for + sign only

jhgj+jgkhk-gjhg+

Like here the count should be 3. In this way I have to find out

1 Like

oh you need both right??
then you can try this (\+|\-)

this will return as 3 count for this string jhgj+jgkhk-gjhg+

Cheers
@Karan28

1 Like

Yes I want both thankyou so much

It worked perfectly

1 Like

Glad!

Cheers
Happy Learning

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.