This question already has answers here:
Using explicitly numbered repetition instead of question mark, star and plus
(4 answers)
Closed 2 years ago.
I have a pattern that I am using and it does everything I need it to except for it does not allow for an 10 digit phone number and not all UK numbers are 11 digits, for example, 01932 783433 is allowed and valid but 01932 78383 is also valid but not allowed;
Pattern:
^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$
I've tried without success to edit the pattern but each time I make a change and think I'm there the pattern starts allowing non numeric characters like 'ext 456' (extension numbers) at the end which is what I am trying to stop.
Is anyone able to help with a solution to make the 11th digit optional without changing anything else?
The comments of changing {3} to {2,3} resolve the issue I was having and the pointer to regex101.com were very useful in understanding my issue.
Related
This question already has answers here:
HTML attribute with/without quotes
(6 answers)
Closed 1 year ago.
What is regarded as best practice when writing HTML, double or single quotes around attribute values, upper- or lower-case attribute names?
Best practice is to use a tool like prettier https://prettier.io
It formats your code every time you save your file. Then you will never have to think about it again.
This question already has answers here:
Proper way to restrict text input values (e.g. only numbers)
(18 answers)
Closed 2 years ago.
User is allowed to enter all the alphabets and numbers but when the special-characters are entered then it shouldn't be entered in the the text box.
I tried doing this using (ng-pattern-restrict) but it's not working as expected, I think it might be possible that it needs to be imported in
app-module.ts but not working.
HTML FILE
#Shashank has a valid point of view. What you want to do is disable the entry of special characters from the backend, as well as render the field invalid from the frontend. A hacker knowing what they're doing would easily manipulate the HTTP Request itself rather than the field, making it pretty vulnerable.
However, if you insist on your solution, I would recommend using RegEx. This sample expression might come in handy. That way, whenever the input field detects one of these special characters, it would replace that character with a ''
This question already has answers here:
Right angle bracket in HTML
(2 answers)
Closed 7 years ago.
I am wondering if the symbol > always needs to be converted into >, if the input is coming from a user? I could understand that < (<) would need to, since the next characters could be interpreted as HTML, but what harm could > have?
It depends what you are going to do with the data. If you're going to render it to a page, it should be HTML-escaped (meaning converted to >). If you're doing pretty much anything else then it should not.
This question already has answers here:
ฏ๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎ํํํํํํํํํํํํํํํํํํํํํํํํํํ Why does this character never end? [closed]
(2 answers)
Closed 9 years ago.
How is possible to do this ʘͥͥͥͥͥͥͥͥͥͥͥͥͥͥ͒_ʘͥͥͥͥͥͥͥͥͥͥͥͥͥͥ͒ in a html input field?
Or this:
ه҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉҉҉҉҉҉҉҉҉҉҉҉҉҉ ه҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉̿҉҉҉҉҉҉҉҉҉҉҉҉҉҉
I just copied and pasted from a Twitter profile. I guess that they are pasting unicode chars in hex but looking at http://www.htmlescape.net/unicode_charts.html I couldn't find any char that overflow vertically or left.
I'm asking because I want to know how this can be avoided. It's possible that people start to use this and break the look and style of many commentable sites, just like I did. Sorry...
It's so called Combining Diacritical Marks. The code in the question, in particular, uses U+0365 COMBINING LATIN SMALL LETTER I character. You can easily create yourself something very similar right in the browser, using this code:
var iMark = String.fromCharCode(869); // 0x365 in decimal
var testString = 'f' + Array(11).join(iMark); // f with 10 dots above
This behaviour (combining all these marks instead of using just a single one) is well described in the official FAQ:
Q: Unicode doesn't contain the character I need, which is a Latin
letter with a certain diacritical mark. Can you add it?
A: Unicode can already express almost anything you will ever need in
any field of study by using a combination of Latin, IPA, or other base
letters with the various combining diacritical marks. For example, if
you need a highly specialized character such as “Z with stroke,
cedilla, and umlaut”, you can get this combination by using three
existing character codes in combination:
U+01B5 LATIN CAPITAL LETTER Z WITH STROKE
U+0327 COMBINING CEDILLA
U+0308 COMBINING DIAERESIS
With appropriate rendering software, that sequence should produce a
glyph combination like this:
Even if the combination is not available in a particular font, it is
unambiguous and Unicode conformant systems should transmit and retain
the sequence without distortion, and it may be processed
programmatically.
How to deal with this (potential) nastiness without affecting the valid texts? One possible approach, I suppose, is normalizing (NFC) the strings first, then stripping away all the non-valid characters.
This question already has answers here:
Can I make a phone call from HTML on Android?
(3 answers)
Closed 9 years ago.
I am making an html link for a phone.
This is what I have:
1-888-888-8888
Will phones recognize this, or do I need to change it to:
1-888-888-8888
Visual separators (except for spaces) are allowed in the uri.
From RFC 3966 "The tel URI for Telephone Numbers":
5.1.1. Separators in Phone Numbers
Phone numbers MAY contain visual separators. Visual separators
('visual-separator') merely aid readability and are not used for URI
comparison or placing a call ... "tel" URIs MUST NOT use spaces in visual separators ...