How to check if string contains numbers symbols - asp.net

I have asp.net(c#) web form with html input text(first name) how i can check if string contains symbols, numbers, unicode text, space with c#
or its more easier with html?
I want to user entered only first name

This regular expression will only match on one or more ASCII characters:
^[A-Za-z]+$
You can use the above in either Javascript or .NET.

Related

Decode (encrypted/encoded) PDF417 Barcode information for Iraqi passport

I need to read PDF417 barcode for Iraqi passport and extract the information from it.
I scanned the barcode successfully and it contains two parts, first part is the MRZ and the second part is an encoded/encrypted text. so is there a way to know the method used to encode this text and how to decode it?
this is the encoded/encrypted part:
|Rk1SACAyMAAAAADcAAABYAF9AMUAxQEAAQA/IEBLAFt0AEBNAH98AEBZAJYAAEBjAMP8AEBmATj0AEB+AEmMAEClADEoAECLAC0oAECJAHEMAECqALQIAECLALgAAECoANsEAEB7AMiAAEB+AUF4AEDIAF0gAEDGAFCkAECzAFIgAECvAKeMAEDlAJQcAEDjAGQgAEDfAPUIAEDCAOOMAEC7AP8AAEDVAVEAAEDBAVCAAEDYASKAAIDFAT0AAED2AJqcAED8AJQcAEDsAQUEAEEVAPmUAEDqAVGEAA==|
Go to https://www.base64decode.org/, copy and paste your text and remove the bar | symbol from the beginning and ending. Then select ISO-8859-6 as the character set and click the DECODE button. You'd have to exclude certain characters from the result to piece together the actual contents.

ASP.NET RegularExpressionValidator False Trigger

I'm validating a password that must be letters and digits with at least one digit and one upper case letter. I am using the following RegEx expression to do so:
(?=(^[a-zA-Z0-9]{6,16})$)(?=.*\d)(?=.*[A-Z])
Using this pattern, the password "Valid101" should be valid and it worked as expected at both A Better .NET Regular Expression Tester and REGEX TESTER. But, when I use it in my ASP.NET user control's RegularExpressionValidator it wrongly decides that password "Valid101" is not valid.
I'm hoping someone could suggest what might be wrong.
The pattern you have only consists of zero-width assertions, of lookaheads. They do not consume the text they match, so the match value after the regex matches is an empty string. The RegularExpressionValidator requires a full string match (i.e. the string matched should be the whole input string).
So, instead of (?=(^[a-zA-Z0-9]{6,16})$)(?=.*\d)(?=.*[A-Z]) use
^(?=.*\d)(?=.*[A-Z])[a-zA-Z0-9]{6,16}$
It will assure there is a digit and an uppercase ASCII letter in the string, and then will match (consume) 6 to 16 ASCII letters and digits.

CSS/JS - Force a line break at a comma in comma separated list

I have a table cell in which there is list of aircraft registration numbers in the format 'X-XXXX'. The width of the table cell means that the list gets word-wrapped on the hyphen, like so:
G-ABCD,G-
EFGH,G-
IJKL
What I'd like to happen is that the line-break is forced on the comma:
G-ABCD,
G-EFGH,
G-IJKL
However, I cannot insert any special characters. This is because when the form is submitted, the data in the table is submitted as JSON format which is then json_decoded in PHP. Any special characters in the comma separated string then stops the json_decode function from turning it into an array.
So I really need a solution that does not alter the list in anyway? Sounds impossible...
To force a line break, use the <br> tag. If you cannot have it in the HTML markup, add it with JavaScript.
This answers the question asked. The actual problem is probably different. You need to post more code and ask differently to have it solved. What is the context, what are the constraints, and what do you actually want to do? (From the discussion in the comments, it seems that you rather want to prevent line breaks after hyphens than force any breaks.)

Regex valid numbers with thousand separator

I'm doing a validation in asp.net textbox, and the textbox only allows user to input number
i.e.
valid numbers:
1234
12.345
12,345,678.231
12,345,678
invalid numbers:
-1234
12.23.45.67
12,
12,34,56
12,345,6
I'm trying to use a regex to validate the user's input on client side with the below regex:
^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$
The problem is:
the above regex only consider below as valid:
1234
12.345
How to modify the above regex to check if the thousand separator being entered into the correct place or not?
this seems to work ^\d+(,\d{3})*(\.\d+)?$
Demo

regular expression validator for a text box to accept a blank value or a single charecter 'C'

what would be the regular expression for a regular expression validator if a text box in my web page can only accept a blank value or charecter 'C'
Thanks
It would be this:
^C$
That indicates that only a single C character will be accepted. Leaving the field empty will also be acceptable, because RegEx validators do not flag empty fields as incorrect.

Resources