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

    Join Date
    Aug 2008
    Rep Power

    "between 0 and X" not working as expected?

    Hello I copied a snippet of JavaScript from a blog, but unfortunately it included all the fancy line numbers and indentation used on the webpage.

    I wanted to quickly strip all those line numbers and extra line returns by making a simple regular expression to find & replace:


    won't match anything in RegExr (google "RegExr Gskinner"), and in sublime text 2 it is matching as expected....

    Why is this?
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power

    I'm pretty sure this pattern is not what you want. It matches any sequence of digits or spaces anywhere in the whole input. If you run it on a piece of code, you'll end up with a mess.

    The first thing you'll need is an anchor to only match digits at the beginning of a line:

    The regex may need further fine-tuning, but I can't tell without seeing the concrete input.

    I have no idea why you get no matches in RegExr. But why does that matter, anyway?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Paris area, France
    Rep Power
    Or get an text editor that can work in column mode to remove the first characters on every line.

IMN logo majestic logo threadwatch logo seochat tools logo