develooper Front page | perl.beginners | Postings from October 2022

Re: escape character in regex

Thread Previous
From:
Henrik Park
Date:
October 11, 2022 02:56
Subject:
Re: escape character in regex
Message ID:
125f4208-1ffa-a383-2738-1729e94669ad@simplemail.co.in
Ken

Thanks for pointing out that.
I was asking this b/c I want to put regex in a variable and use it for 
matching.

such as this one in java/scala:

scala> val regex = """\w+\$\w+\$\w+""".r
val regex: scala.util.matching.Regex = \w+\$\w+\$\w+

scala> str
val res72: String = hello$world$buddy

scala> regex.matches(str)
val res73: Boolean = true


regards



Ken Slater wrote:
> Therefore, you need to escape the dollar sign ($) as follows:
>        my $delimiter = '\$';
> To indicate that you are using the dollar sign ($) as a character.

-- 
Simple Mail
https://simplemail.co.in/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About