Tabs are ascii character 0x09; spaces are 0x20. Replacing spaces will not affect tabs…
$str = "1 2 3\t4 5 6\t7 8 9\n";
$str =~ s/ //g;
# $str is now "123\t456\t789\n"
Take a look at perlrequick for an introduction to regular expressions.
More Related Contents:
- string pattern matching using perl regex [closed]
- Awk – replace coumn 2 in table 1 from coumn 2 in table 2 based on matching data in column 1 (common between tables)
- Match whitespace but not newlines
- The recognizing power of “modern” regexes
- Should I use \d or [0-9] to match digits in a Perl regex?
- Escaping a forward slash in a regular expression
- How can I use a variable in the replacement side of the Perl substitution operator?
- When is \G useful application in a regex?
- Using alternation or character class for single character matching?
- Why is a character class faster than alternation?
- What regex can match sequences of the same character?
- How to extract string following a pattern with grep, regex or perl [duplicate]
- regex to match word boundary beginning with special characters
- Regex to match any character including new lines
- Does the ‘o’ modifier for Perl regular expressions still provide any benefit?
- How do I handle special characters in a Perl regex?
- How can I find the location of a regex match in Perl?
- How can I exclude some characters from a class?
- Can I use Perl regular expressions to match balanced text?
- What is the difference between \1 and $1 in a Perl regex?
- How do I perform a Perl substitution on a string while keeping the original?
- How can I match a quote-delimited string with a regex?
- How can I use a variable for a regex pattern without interpreting meta characters?
- How can I parse quoted CSV in Perl with a regex?
- how to match a number which is less than or equal to 100?
- How to escape dollar sign ($) in a string using perl regex
- Can I substitute multiple items in a single regular expression in VIM or Perl?
- How to use different separators (/ , |) in a regular expression
- Counting number of occurrences of a string inside another (Perl)
- How to replace a string in an existing file in Perl