# Thread: Matching 2 variables when one contains extra text

1. ## Matching 2 variables when one contains extra text

What is the easiest way to check that 2 variables match when one of them always contains some extra text that I want to ignore?

A = Smith, John J
B = Smith, John J (ABCD)

I want to ignore the (ABCD). The ABCD could vary in length so I could not just cut off the last 10 character or so.

Thanks!

2. ## Re: Matching 2 variables when one contains extra text

You can split the array where the first paranthesis starts:

A = "Smith, John J"
B = "Smith, John J (ABCD)"

B = Split(B, "(")(0)

MsgBox Trim(A) = Trim(B)

3. ## Re: Matching 2 variables when one contains extra t

look for Instr in QTP help

Regards,
Mobin

4. ## Re: Matching 2 variables when one contains extra text

[ QUOTE ]
You can split the array where the first paranthesis starts:

A = "Smith, John J"
B = "Smith, John J (ABCD)"

B = Split(B, "(")(0)

MsgBox Trim(A) = Trim(B)

[/ QUOTE ]

Thanks! That worked perfectly. Just out of curiosity, what does the "(0)" do? I wasn't quite sure what the Split help was talking about.

5. ## Re: Matching 2 variables when one contains extra text

if instr(1,b,a,vbtextcompare)&gt;0 then
msgbox "Found"
else
endif

I sometimes get the position of a and b the wronf way around!
If this doesnt work swap a and b!

Peace

6. ## Re: Matching 2 variables when one contains extra text

[ QUOTE ]
I sometimes get the position of a and b the wronf way around!
If this doesnt work swap a and b!

[/ QUOTE ]

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:09 AM.