473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

compare two string and get the difference

Hi there,
I am trying to compare two strings and get the differenc
in vbscript.

Example: Str1="This is a test text"
Str2="This is a fine test text but a little long"
I like to compare str1 with str2 and get the difference.
Above example the difference will be "fine" and "but a
little long"
How do I do that? A sample code would be apprciable.

Thanks for your time

Jyoti
Jul 19 '05 #1
3 5792
actually that isnt' the "difference". Technically you'd have to do a
position by position check or a word by word check, splitting it on the " "
(spaces) which isn't accurate really though.

There really is no direct way to get these differences directly. Could you
explain a little more on the idea you are trying to get to?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"jyoti" <mu*************@hotmail.com> wrote in message
news:18*****************************@phx.gbl...
Hi there,
I am trying to compare two strings and get the differenc
in vbscript.

Example: Str1="This is a test text"
Str2="This is a fine test text but a little long"
I like to compare str1 with str2 and get the difference.
Above example the difference will be "fine" and "but a
little long"
How do I do that? A sample code would be apprciable.

Thanks for your time

Jyoti

Jul 19 '05 #2
Thanks for your reply..

I am developing a web site content managment system for our
organization. Anybody changes anything on the content of the web site,
goes through a review process. When somebody make any update and upload
to pre-production area, the system sends an email to reviewer to review
the update. The email contains a URL where reviewer can view the updated
page.

I have two folders. One is original folder and the other one is Update
folder.

I like to highlight the updated area when reviewer visits the url to
review.

Example:
At Original Folder:
Test.txt file contains " This is a test text"
At Update Folder:
Test.txt file contains "This is a fine text blala"
I like to highlight the word "fine" and "blala".

I can go line by line and compare both files. If lines are different
then I can highlight the whole line on Test.txt on update folder. But
the problem is if line is too long and user makes just one or two words
update, then it will highligh the un-neccessary area.

Any suggestion..

Thanks for your time.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
what I'm saying though is that

"Hello my name is Curt" campared with
"Hello There my name is Curt" doesnt' result in only showing "There" as the
difference. EVERYTHING from the word "There" on is different technically,
it's all shifted over one word.

I would say do a LINE comparison, just indicating that the LINE has changes,
but again, if anything shifts down a line EVERY line from that point on will
be "changed".
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Muhammad Rahman" <mu*************@hotmail.com> wrote in message
news:ef**************@tk2msftngp13.phx.gbl...
Thanks for your reply..

I am developing a web site content managment system for our
organization. Anybody changes anything on the content of the web site,
goes through a review process. When somebody make any update and upload
to pre-production area, the system sends an email to reviewer to review
the update. The email contains a URL where reviewer can view the updated
page.

I have two folders. One is original folder and the other one is Update
folder.

I like to highlight the updated area when reviewer visits the url to
review.

Example:
At Original Folder:
Test.txt file contains " This is a test text"
At Update Folder:
Test.txt file contains "This is a fine text blala"
I like to highlight the word "fine" and "blala".

I can go line by line and compare both files. If lines are different
then I can highlight the whole line on Test.txt on update folder. But
the problem is if line is too long and user makes just one or two words
update, then it will highligh the un-neccessary area.

Any suggestion..

Thanks for your time.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
8
by: Sharon | last post by:
hi, I want to compare character, if the string contains character "-" then it will print Hello on the screen however, neither method (1) nor method (2) work in the code below: so what the correct...
19
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I...
4
by: Sasidhar Parvatham | last post by:
Hi All, How do I compare two strings and get all the positions where there is a difference between them? Thanks, Sasidhar
3
by: dotnetnoob | last post by:
i have two strings from xml file str1 = 800.7415_801.101_8.115_216.12 str2 = 800.7415_801.101_8.115_216.12_217.570 the first stream represent a xml file 800.7415_801.101_8.115_261.12.xml...
11
by: balakrishnan.dinesh | last post by:
hi frnds, Im having two 20digit numbers, But while comparing those it is giiving wrong ouput in javascript. for example here is my code, my secanrio is , ~ If first 20 digit number is...
4
by: Lamis | last post by:
Hi, what is the best way to compare 2 haschtables contatining objects. the objects has 2 property, name & value. I need to print out the differences -- LZ
3
by: artev | last post by:
in the default sort which is the compare function used? alphabetical ordination is so:arry.sort(); but which is the default function used? is there a good link wich example for alphabetical...
6
by: Muhs | last post by:
Hi !! i want to compare two strings and return the difference For example, i have two strings, string str1="then"; string str2="than"; it compared the two strings and returns 1, as only one...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.