Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: difference between two lines

by Corion (Patriarch)
on Jul 30, 2018 at 08:18 UTC ( [id://1219459]=note: print w/replies, xml ) Need Help??


in reply to difference between two lines

What have you tried and how did your code fail?

Some ideas would be:

You could remove all spaces from both lines. If they are equal, the difference was only the blank space.

If you want to know if two lines only differ by exactly one blank space, check first, if the absolute difference in their lengths is 1. Then do the above check.

Alternatively, split both strings on spaces and check if the resulting lists are the same.

Replies are listed 'Best First'.
Re^2: difference between two lines
by vinoth.ree (Monsignor) on Jul 30, 2018 at 09:13 UTC
    Hi Corion

    I tried the first option(remove all spaces from both lines and compare). I thought there could be best way, that's why posted this question.


    All is well. I learn by answering your questions...

      So the first option worked? If so, there's no need for a "best way". If your code has some issues you'll have to be more specific, rather than hope someone provides a solution actually fits your needs without knowing them. Or if you want advice about your code, you'll have to post it.

      Edited: in hindsight my previous formulation sounded harsher than intended.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1219459]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found