LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help to find the internal consonants in a string.

Solved!
Go to solution

@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.

0 Kudos
Message 11 of 18
(576 Views)

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;

[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.

0 Kudos
Message 12 of 18
(572 Views)

@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"

wiebeCARYA_0-1693383464617.png

 

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.

 

0 Kudos
Message 13 of 18
(563 Views)

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

 

Basjong53_0-1693384208613.png

 

0 Kudos
Message 14 of 18
(557 Views)

@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)

wiebeCARYA_0-1693394532441.png

The reg.ex. scales up better to match 3 internal consonants:

CURP.png

 

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

CURP2.png

 

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...

0 Kudos
Message 15 of 18
(538 Views)

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.

0 Kudos
Message 16 of 18
(523 Views)

@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:

CURP3.png

0 Kudos
Message 17 of 18
(516 Views)

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! 

Message 18 of 18
(482 Views)