Regular expression for City name
-
I have two scenarios in table one is name of person and another is cityname but both name of the person and cityname starts with capital letter and followed by small letters I want different regular expression for cityname and name of person but both starts with capital letter and followed by small letters how can I differentiate them with regular expression.
-
I have two scenarios in table one is name of person and another is cityname but both name of the person and cityname starts with capital letter and followed by small letters I want different regular expression for cityname and name of person but both starts with capital letter and followed by small letters how can I differentiate them with regular expression.
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."
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
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."
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
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
-
I have two scenarios in table one is name of person and another is cityname but both name of the person and cityname starts with capital letter and followed by small letters I want different regular expression for cityname and name of person but both starts with capital letter and followed by small letters how can I differentiate them with regular expression.
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 isStoke-on-Trent
. There's probably other names for both people and cities that don't fit your expected pattern. Consider, isRegina
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
-
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.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
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.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
XML element looks like for name of person And in the same XML for cityname And in same XML cityname having all caps letter like So suggest me regular expression for Cityname for both cases Birmingham and BIRMINGHAM because I want to proceed name for different function and cityname for different function in data masking tool. And regular expression for name of person like "Jeff"
-
XML element looks like for name of person And in the same XML for cityname And in same XML cityname having all caps letter like So suggest me regular expression for Cityname for both cases Birmingham and BIRMINGHAM because I want to proceed name for different function and cityname for different function in data masking tool. And regular expression for name of person like "Jeff"
You really are determined to ignore what you're being told, aren't you?! :doh: 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
-
XML element looks like for name of person And in the same XML for cityname And in same XML cityname having all caps letter like So suggest me regular expression for Cityname for both cases Birmingham and BIRMINGHAM because I want to proceed name for different function and cityname for different function in data masking tool. And regular expression for name of person like "Jeff"
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.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
You really are determined to ignore what you're being told, aren't you?! :doh: 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
Richard Deeming wrote:
or a Vulcan mating ritual.
:laugh: :laugh: :laugh:
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
I have two scenarios in table one is name of person and another is cityname but both name of the person and cityname starts with capital letter and followed by small letters I want different regular expression for cityname and name of person but both starts with capital letter and followed by small letters how can I differentiate them with regular expression.
It's impossible. Suppose you are just looking at surname and city, then my local city defeats this. Am I looking for the magician with the surname Durham[^], or the city in England[^]?
-
You really are determined to ignore what you're being told, aren't you?! :doh: 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
-
You really are determined to ignore what you're being told, aren't you?! :doh: 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
-
I have two scenarios in table one is name of person and another is cityname but both name of the person and cityname starts with capital letter and followed by small letters I want different regular expression for cityname and name of person but both starts with capital letter and followed by small letters how can I differentiate them with regular expression.
KiranKumar V 2024 wrote:
regular expression for cityname and name of person
You stated in the other post
Go to ParentXML element looks like for name of person
And in the same XML for cityname
And in same XML cityname having all caps letter like
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. https://en.wikipedia.org/wiki/List\_of\_places\_in\_the\_United\_States\_named\_after\_people 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.
-
KiranKumar V 2024 wrote:
regular expression for cityname and name of person
You stated in the other post
Go to ParentXML element looks like for name of person
And in the same XML for cityname
And in same XML cityname having all caps letter like
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. https://en.wikipedia.org/wiki/List\_of\_places\_in\_the\_United\_States\_named\_after\_people 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.
jschell wrote:
If you find it is a city. If you don't it is a name.
Paris[^]? Durham[^]? London[^]? Adelaide[^]? Etc. There are plenty of examples that could be either a city or a name. Using not in the list of cities === person test might give you a good start, but its never going to be 100% accurate. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
jschell wrote:
If you find it is a city. If you don't it is a name.
Paris[^]? Durham[^]? London[^]? Adelaide[^]? Etc. There are plenty of examples that could be either a city or a name. Using not in the list of cities === person test might give you a good start, but its never going to be 100% accurate. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer