Also, if you use the library functions for parsing floating point values, they will/may consider the culture. In many European cultures, a decimal comma is used, not a decimal point. The point is used a digit group separator.
Programming code literals (almost?) always follows the English tradition of decimal point, and comma as group separator. User input is different. You can't make all users switch to a different number syntax just because your program doesn't honor the local culture.
A minor non-regex comment to the OP: If you intend the check
Case 2. (ui >= 0.0000) & (ui <= 65536.0000)
to verify that the number can be converted to a 16 bit uint, then it should be either (ui < 65536.0000) or (ui <= 65535.0000).
(But then, I think it curious to verify a floating point number against the value limits of an integer type. A numeric value is either a measurement or a count. Re-interpreting a measurement as a count is a strange thing to do.)
Religious freedom is the freedom to say that two plus two make five.
However, the expression is not as difficult as is said here.
At the special request of a single person, the regular expression now also accepts "." and ",".
I program in QT and QLineEdit can be configured very nicely and effectively with regex expressions. I would therefore be very reluctant to deviate from this.
I am programming an LCR measuring bridge front end from Analog Devices (ADMX2001). The tDelay value range between 0.0000 and 65536.0000 is expected by the frontend and is also checked. And the value range does not fit into a uint16. Should I now discuss the specified value range with Analog Devices ? They must know in which way the bridge operates.
This makes no sense at all. What you've said is you have Person names and City names, both using the sexact same format, a capital letter followed by lower-case letters. There is no way to "differentiate them", whatever that means, with a single RegEx.
You're going to have to do a better job of explaining what the data you're dealing with is like, and a much better explanation of what you mean by "differentiate them."
I am working with Data masking in test data management there we are using one tool called javelin workflow to extract data from XML which is inserted into database and
To read data we are using regular expression pattern for name and cityname.
But our requirement is city name like Birmingham should be masked as fixed value as Norwich and name of person should be masked as random letters, but we are using same regular expression pattern for both and data is not masking as we expected so we want to differentiate them with regular expression
If this is coming from an XML file, you SHOULD have fields in the XML specific to each type of name. If not, you have very badly malformed data in the file making it pretty much useless, unless there is another field in the same record telling you what type of name is in the record. Without that discriminator field, the data you're pulling from the XML is useless.
You cannot use a RegEx to distinguish between a person name and a city name in the same field. It's just not possible, even for a human to determine by hand.
You really are determined to ignore what you're being told, aren't you?!
It is literally impossible to use a regex to determine whether a sequence of characters refers to a person, a city, a talking kangaroo, or a Vulcan mating ritual.
Your only hope is to get a massive database containing the name of every single city on Earth, and hope that anything that's not in that list refers to a person. And even that's not foolproof - for example, "Paris" could be a city or a person. Without more details, you have no way of knowing.
The data you're trying to process is garbage. If you need to be able to tell whether the data refers to a person or a city, then you need to go back to the people providing the data and get them to add something into the data to distinguish the two. Assuming they know the difference in the first place!
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
It's simply not possible. There is no expression that will be able to tell you whether the name is a person or a city. NONE AT ALL.
If you're trying to extract the names from the XML file, you DO NOT USE A REGEX FOR THIS. You create classes to hold each type of record and deserialize the XML into a data structure using those classes.
But, since you're get both city names and person names in the same record type (whatever "ab" means), there is no code you could ever write to tell you whether that is a person or a city.
Based on your description, it would seem that New York is not a valid name for either a person or a city. I'm pretty sure it is a city. So is Stoke-on-Trent. There's probably other names for both people and cities that don't fit your expected pattern.
Consider, is Regina a person or a city? I know people named Regina. I know of a city named Regina. How would you differentiate between the two?
I don't think that a regex is the right tool for this. I'm pretty sure both person and city names are far more complex than you've allowed for.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
regular expression for cityname and name of person
You stated in the other post
Go to ParentXML element looks like for name of person
<ab ov="Jeff" v="Jeff" id="1">
And in the same XML for cityname
<ab ov="Birmingham" v="Birmingham" id="2">
And in same XML cityname having all caps letter like
<ab ov="BIRMINGHAM" v="BIRMINGHAM" id="3">
As suggestion from another response it is NOT possible for you to determine from the above which is a city and which is a persons name.
HOWEVER, what you posted is not valid XML. It would seem possible to me that there are other XML elements that you can use.
But if not then I would immediately point out to whoever assigned this to you that it is NOT deterministic. A computer can NOT solve the problem correctly. Doesn't matter how you do it.
But with you posted the ONLY solution you have right now would be with the following.
- You must buy a city database. That is a product/service that one pays money for.
- You then use XML to parse the data. You do NOT use regular expressions to parse it.
- You look up the each value in the database. If you find it is a city. If you don't it is a name.
Following is an actual list of cities named after people. So of course these are the one that a computer cannot tell the difference. Actually human will not be able to tell it either.
Now in terms of other possibilities.
- There is in fact a person name AND city name in each record. So you could use that in combination with the above.
- As I said there are other elements/attributes in the XML that define exactly what it is.
- You can request that they change the XML to make it clear which is a city and which is a name.