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

Re: escape character in regex

Thread Previous
Henrik Park
October 11, 2022 02:56
Re: escape character in regex
Message ID:

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

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


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

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About