Closed Thread
Results 1 to 5 of 5

Thread: find and replace 20 number in word

  1. #1
    user22 is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    find and replace 20 number in word

    hi all,
    i need to replace number 20 in following word with space.
    please help me to write regular exprssion for it.

    only2020%20left20on20/,

    i have written the ~s/20/ /g; it works but it replaced second 20 number also in this word
    output of this :
    only % left on /,
    i want output: only 20% left on /,
    please help me to write regular expresion for this.
    Thanks in advance.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: find and replace 20 number in word

    You want to replace %20, not 20.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0

    Re: find and replace 20 number in word

    this question has been answered and resolved on another forum.

  5. #4
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: find and replace 20 number in word

    Okay, well what is the solution?

    Might help somebody else to know what the solution was.

  6. #5
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0

    Re: find and replace 20 number in word

    Fair enough, as posted on codingforums:

    You can use a negated lookahead assertion:

    Code:
    $_ = 'only2020%20left20on20/,';
    s/20(?!%)/ /g;
    print;
    means to replace 20 with a space if it is not proceeded by the % symbol

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. find number in string? (4w3d10:22:22)
    By Hamed in forum PHP Development
    Replies: 1
    Last Post: 08-23-2011, 10:06 AM
  2. Notepad Find,Find Next ,replace,goto Code
    By shyamenk in forum C# Programming
    Replies: 7
    Last Post: 04-06-2011, 08:25 PM
  3. Find and replace multiple letters
    By Renee55 in forum Java Help
    Replies: 5
    Last Post: 09-20-2010, 09:15 AM
  4. Find and Replace in online html page
    By panther45 in forum General Programming
    Replies: 0
    Last Post: 02-11-2010, 05:33 PM
  5. How do i find the combination of a 7 letter word?
    By mr_skyflakes21 in forum Java Help
    Replies: 5
    Last Post: 03-28-2009, 12:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

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