Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Escape Quote in Regex within input tag

Tags:

python

html

regex

I have an input tag within my python code the looks like this:

<input class="form-control input-lg" type="text" name="name" value="value" placeholder="placeholder" required pattern="^[a-zA-Z0-9.@#$()+! \'_-]+$">

I was able to escape the single quote ' in the required pattern ' but anytime I try to add a double quote ", then it closes the previous double quote (pattern="). I am looking to achieve something like:

pattern="^[a-zA-Z0-9.@#$()+! \'\"_-]+$">

where the \" should allow me to escape the quote but clearly that doesn't work like the \' works. Any help would be greatly appreciated.

like image 461
Ryan Clark Avatar asked Feb 16 '26 11:02

Ryan Clark


1 Answers

pattern="""^[a-zA-Z0-9.@#$()+! \'\"_-]+$"""

You can use """ instead.

like image 60
vks Avatar answered Feb 18 '26 03:02

vks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!