Search code examples
regexperl

Regular Expression to match one or more backslashes and + signs


I am writing a regular expression to match one or more \ and one or more + signs. This is what I have so far and it doesn't look like its right

/\\+\++/

my $test = "\+";

if( $test =~ /\\+\++/)
{

    print "yes";

}

Ive tried this code and it doesn't work


Solution

  • You're expression is fine as is, though you may want to add anchors if the whole string should be made up of only \ & + characters.

    /^\\+\++$/g