white space validation not working [duplicate] - django

This question already has answers here:
(Django) Trim whitespaces from charField
(6 answers)
Closed 8 years ago.
forms.py
I want to validate white space for following fields name1,name2 and name3.I tried the same in clean(),where i did other validation.Only white space validation is not accepting.
Thanks

Have you thought about using a RegexField, which would only accept the formats (incl whitespace) you want?
See RegexField in the docs

Related

how can I write #... email pattern , using regix [duplicate]

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 2 years ago.
I want to validate an email field using regex in such a way that my email has to has #moore in it.
like a#moore.af, b#moore.sg, and so on. how can I write its pattern? I am using typescript and angular reactive form.
Your help is much appreciated.
You can try to use ([\w-\.]+#moore\.[\w+]{1,5}) to match an email address, as I left a 1-5 characters' space for the domain name.
In JavaScript flavour: const regex = /([\w-\.]+#moore\.[\w+]{1,5})/gm; then you can use regex.test(str) to validate the email field.
Edit:
As #Toto pointed out, This regex matches .....#moore.++++. Better regex would be:
([a-zA-Z0-9\.-]+#moore\.[a-zA-Z0-9\.]{1,5})
to only accept alphabet/number in the domain name.

IIS URL Rewrite Match # in part of URL [duplicate]

This question already has answers here:
How does IIS URL Rewrite handle # anchor tags
(1 answer)
How to get Url Hash (#) from server side
(6 answers)
Closed 2 years ago.
I can't get IIS to match a URL with a #. Instead It trims the URL at the #
/product name to match #1.html
^seeds/([A-Za-z0-9-_ #]+).html/?$
I've tried escaping it, to no avail.
Result from IIS is /product name to match
Any ideas?
N.B. whoever marked my question as answered elsewhere please read my question again.

How to allow underscore in email regex in coldfusion [duplicate]

This question already has answers here:
How can I validate an email address in JavaScript?
(79 answers)
How can I validate an email address using a regular expression?
(79 answers)
Closed 4 years ago.
hi i am using the regex to validate the email but when i try to user underscore in email address than is giving me the error.
Following is regx which i am using.
^[a-zA-Z0-9-'+~]+(.[a-zA-Z0-9-'+~]+)*#([a-zA-Z_0-9-]+.)+[a-zA-Z]{2,10}$
if (not isValid("regex", arguments.propertyValue,"^[a-zA-Z0-9-'\+~]+(\.[a-zA-Z0-9-'\+~]+)*#([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,10}$")) {
}
can any one please let me know which regx should i use?

Regex: Get first value from single line [duplicate]

This question already has answers here:
Can you provide some examples of why it is hard to parse XML and HTML with a regex? [closed]
(12 answers)
RegEx match open tags except XHTML self-contained tags
(35 answers)
Closed 7 years ago.
I have the below xml on a single line, I want to get the string of DBB and replace it using regex
<Configuration ConfiguredType="Property" Path="\Package.Connections[DBA DB].Properties[ConnectionString]" ValueType="String"><ConfiguredValue>Data Source=.\test;Initial Catalog=DBA;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Application Name=B;</ConfiguredValue></Configuration><Configuration ConfiguredType="Property" Path="\Package.Connections[DBB DB].Properties[ConnectionString]" ValueType="String"><ConfiguredValue>Data Source=.\test;Initial Catalog=DBB;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Application Name=C;</ConfiguredValue></Configuration></DTSConfiguration>
I have the following which works on multi line xml but not this single line example
Data Source=.+?(?=[a-z])*\;Initial Catalog=DBB;(.*?)Integrated(.*?)[^;]*;
The above regex highlights both DBA and DBB and ends there.
Could you help in finding the missing piece in the regex I have created
Replace Data Source=.+? with Data Source=[^<]+? to avoid traversing the start of the tag.

Need a simple reg ex for url checking [duplicate]

This question already has answers here:
What is the best regular expression to check if a string is a valid URL?
(62 answers)
Closed 9 years ago.
I am looking for it about 2 hours, but can not find what I need.
what I need is very simple:
allow: google.com, http://google.com, https://google.com
disallow spaces "goo gle.com"
with a valid domain: I mean it should have a dot "." + any domain (.com, .net etc.)
and allow anything after that: "googl.com/dsfsdf/sdfs/blablahblah/" without spaces
thanks
Edit:
Thanks all, I had to write it myself.
if (!/^((ftp|http|https):\/\/)?([a-z0-9_\.-]+)\.{1}([a-z0-9_\/\?\=\-\%-]+)$/.test(uri)
|| /([\._\/\?\=\-\%-])\1/.test(uri)) {
}
ps: I am noob in regexs.
www.google.com
http://www.google.com
mailto:somebody#google.com
somebody#google.com
www.url-with-querystring.com/?url=has-querystring
The REGEX below matches all the above cases
((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+#)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+#)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%#.\w_]*)#?(?:[\w]*))?)
REGEX Explanation can be found here
Working Example
Something that's working for me on a production product (haven't received any complaints yet):
((www\.|(http|https|ftp|news|file)+\:\/\/)?[_.a-z0-9-]+\.[a-z0-9\/_:#=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])