#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2019
    Posts
    2
    Rep Power
    0

    Simple question: How to remove a space from a number with a RegEx string


    G'day,

    I'm new to RegEx and have been searching for hours for what I thought would be simple.

    I use a web data scraping tool to extract price levels for stocks to save into a Excel worksheet.
    The levels it scrapes presents as numbers like 68.29 8 or 2546.99 8

    Each number will have a space before the last digit. I want to remove the space so I get 68.298 or 2546.998 as whole numbers.
    The data scraping tool allows me to enter a regex string to do this. As far as I can get is [0-9.,]+ which returns the numbers before the space

    Can someone please suggest a string that will do this. I have searched for hours and need to move foward

    Thanks
  2. #2
  3. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,977
    Rep Power
    9647
    If the tool lets you capture and replace multiple groups then capture one numeric group, a space, and capture the second group, then replace them with the first+second group.

    If the tool lets you do a sort of string replacement then match the space and remove it.

    If the tool doesn't let you do either then I'm not sure you can do anything at all with it.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2019
    Posts
    2
    Rep Power
    0
    Originally Posted by requinix
    If the tool lets you capture and replace multiple groups then capture one numeric group, a space, and capture the second group, then replace them with the first+second group.

    If the tool lets you do a sort of string replacement then match the space and remove it.

    If the tool doesn't let you do either then I'm not sure you can do anything at all with it.
    Thanks Mate for the reply

    The scraping tool, (DataToolBar), cannot select the space because a space is not there on the web page.
    The last digit of the stock level as it's displayed in the web page is in a smaller font. ie 68.298 (For some reason i cannot change the 8 to a smaller font on here)
    Then after the capture a space is inserted.

    If we put the tool to one side for a sec, if I had a string of 68.29 8, is there a RegEx command possible to remove the space
    and display 68.298
  6. #4
  7. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,977
    Rep Power
    9647
    Yes, it's just basic "match a space and replace with nothing". In Perl parlance, s/ //. It's so simple it's not even something you'd normally use a regular expression for, it's only simple string replacement.

IMN logo majestic logo threadwatch logo seochat tools logo