08-30-2023 02:47 AM
@Basjong53 wrote:
I haven't seen a solution yet, this is one way:
I lost track of the problem... It seems a bit lucid.
I don't think there will be a solution. At least not until there's a list of inputs with expected outputs.
08-30-2023 02:57 AM
wiebe@CARYA wrote:
@Basjong53 wrote:
I haven't seen a solution yet, this is one way:
I lost track of the problem... It seems a bit lucid.
I don't think there will be a solution. At least not until there's a list of inputs with expected outputs.
He stated the problem... He wants to replicate the CURP. It is clearly defined: https://en.wikipedia.org/wiki/Unique_Population_Registry_Code. He wants to know how to do these points:
[quote]
For example, the CURP code for a hypothetical person named Gloria Hernández García, a female, born on 27 April 1956 in the state of Veracruz, could be HEGG560427MVZRRL04.
[/quote]
In the example given, Gloria Hernández García will become RRL (the last 3 letters in the example CURB). My solution gives you exactly these letters.
08-30-2023 03:23 AM
@Basjong53 wrote:
wiebe@CARYA wrote:
@Basjong53 wrote:
I haven't seen a solution yet, this is one way:
I lost track of the problem... It seems a bit lucid.
I don't think there will be a solution. At least not until there's a list of inputs with expected outputs.
He stated the problem... He wants to replicate the CURP. It is clearly defined: https://en.wikipedia.org/wiki/Unique_Population_Registry_Code. He wants to know how to do these points:
- The first surname's first inside consonant;
- The second surname's first inside consonant;
- The first given name's first inside consonant;
Ok, OP's (he or she btw) goal is clear... Still the problem with achieving the goal is a bit fuzzy.
@Basjong53 wrote:[quote]
For example, the CURP code for a hypothetical person named Gloria Hernández García, a female, born on 27 April 1956 in the state of Veracruz, could be HEGG560427MVZRRL04.
[/quote]
In the example given, Gloria Hernández García will become RRL (the last 3 letters in the example CURB). My solution gives you exactly these letters.
Your solution seems to give an "E"
If the goal is to get the last 3 letters, what's the fuzz about internal consonants?
Guess I'd have to read that wiki... Don't think I will though. I'll wait for the TL;DR version.
08-30-2023 03:30 AM
wiebe@CARYA wrote:
If the goal is to get the last 3 letters, what's the fuzz about internal consonants?
Uhm, no? I literally quoted the TL:DR of the wiki page... The last 3 letters of the CURP are obtained from the persons given name and 2 surnames.
wiebe@CARYA wrote:
@Basjong53 wrote:
He wants to replicate the CURP. It is clearly defined: https://en.wikipedia.org/wiki/Unique_Population_Registry_Code. He wants to know how to do these points:
- The first surname's first inside consonant;
- The second surname's first inside consonant;
- The first given name's first inside consonant;
Hernández -> R
García -> R
Gloria -> L
08-30-2023 06:45 AM
@Basjong53 wrote:
wiebe@CARYA wrote:If the goal is to get the last 3 letters, what's the fuzz about internal consonants?
Uhm, no? I literally quoted the TL:DR of the wiki page... The last 3 letters of the CURP are obtained from the persons given name and 2 surnames.
wiebe@CARYA wrote:
@Basjong53 wrote:
He wants to replicate the CURP. It is clearly defined: https://en.wikipedia.org/wiki/Unique_Population_Registry_Code. He wants to know how to do these points:
- The first surname's first inside consonant;
- The second surname's first inside consonant;
- The first given name's first inside consonant;
Hernández -> R
García -> R
Gloria -> L
That makes sense now you give the context. Or maybe I'm just slow (dislektic 😋).
It is at least partially your interpretation, as OP mentions the input is 2 words (even though CURP specifies 3 names)
I'd do to match the first internal consonant (although this can be done with a match pattern too)
The reg.ex. scales up better to match 3 internal consonants:
Defined inputs and expected outputs would still be good to have. Especially for non-confirming inputs (2 names, no internal consonant, etc).
It might be cleaner to simply get one name's consonant, and repeat it 3 times
Of course, you can do that with your solution too, but you'd have to add a split on the spaces.
Provided the input is is a string of 3 names. Or is it an array of 3 names? Can the be 2 names? Etc...
08-30-2023 07:39 AM
wiebe@CARYA wrote:
Of course, you can do that with your solution too, but you'd have to add a split on the spaces.
Provided the input is is a string of 3 names. Or is it an array of 3 names? Can the be 2 names? Etc...
Exceptions are explained in the wiki (if 2 names are given, the second last name will be an X, etc..), but the nuances are for the OP to figure out 😉
A regex exists for (almost) all string filter (email.. 😒), but becomes unreadable quick, sometimes simplicity is better in my opinion. Just a for loop parsing each name would be easiest to implement and maintain.
08-30-2023 08:12 AM
@Basjong53 wrote:
wiebe@CARYA wrote:
Of course, you can do that with your solution too, but you'd have to add a split on the spaces.
Provided the input is is a string of 3 names. Or is it an array of 3 names? Can the be 2 names? Etc...
Exceptions are explained in the wiki (if 2 names are given, the second last name will be an X, etc..), but the nuances are for the OP to figure out 😉
A regex exists for (almost) all string filter (email.. 😒), but becomes unreadable quick, sometimes simplicity is better in my opinion. Just a for loop parsing each name would be easiest to implement and maintain.
One can also go Scan From String on this one:
08-31-2023 03:58 PM
This seems to be solving the issue. Of course exceptions and other validations will be my turn to solve, sorry it took me so long to answer as well.
Thank you!