Jump to content
  • 0

Opzoeken code in tekstveld


edc

Question

Posted

Ik heb een lijst van 65000 tagnamen. In ongeveer 80% van deze namen komt op een willekeurige plaats een code voor met volgend formaat: ANNNN_NN . Waarbij A staat voor alfa-numeriek en N voor numeriek karakter. De bedoeling is nu uit het veld met de namen, in een tweede veld de bewuste code te verkrijgen. Misschien nog een voorbeeld ter verduidelijking. In veld 1 staat bv: "METINGWINDOW_P0612_02U.max-max". In veld2 moet dus P0612_02 komen te staan. In een volgend record staat dan bv:"AG09_D0006_07XS_FAULT3.EventTrans#1", in veld2 moet D0006_07 komen te staan. (Soms staat de code ook vooraan) .Hoe kan ik dit oplossen?

7 answers to this question

Recommended Posts

  • 0
Posted

Try this one:

 

Middle(code;

Position(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(code;

"A";"A");"B";"A");"C";"A");"D";"A");"E";"A");"F";"A");"G";"A");"H";"A");"I";"A");"J";"A");"K";"A");"L";"A");"M";"A");"N";"A");"O";"A");"P";"A");"Q";"A");"R";"A");"S";"A");"T";"A");"U";"A");"V";"A");"W";"A");"X";"A");"Y";"A");"Z";"A");"0";"N");"1";"N");"2";"N");"3";"N");"4";"N");"5";"N");"6";"N");"7";"N");"8";"N");"9";"N")

; "ANNNN_NN" ; 1; 1); 8 )

 

HTH,

Stef

  • 0
Posted

Dit wil ik proberen te begrijpen :)

 

Wat deze berekening dus doet is alle voorkomende letters naar een A omzetten en alle voorkomende cijfers naar een N. Vervolgens wordt er gezocht waar in de gesubstitueerde reeks de sequentie ANNNN_NN voorkomt, en dan? Dan wil je dus nog terug naar de originele "string" en weet je per record waar je moet beginnen met lezen om die code eruit te extraheren? Is het zoiets? :?:

  • 0
Posted

Dat doet de Stef niemand na... Lijkt me een ideaal iets voor de confituursessie. In http://www.avd-ci.be/tip_f.htm zie je dat de Tip "De wondere wereld van de Substitute-functie" pas voorzien is als tip 174, dat is dus pas medio volgend jaar (we werken met FiFo). En zo lang kunnen we niet wachten! Wat denk je, Stef?

  • 0
Posted

Ik ben onder de indruk. En het werkt dan nog ook. Alleen nog één probleempje waar Stef hopelijk ook nog raad mee weet. Wanneer de gevraagde code niet gevonden wordt geeft de formule als resultaat de eerste 8 karakters van het te onderzoeken veld. Dit zou eigenlijk blank moeten zijn zodat ik de recordset kan selecteren met de effectief gevonden codes. Bedankt op voorhand. En ik ben het volmondig eens met AvD.

  • 0
Posted

Bedankt voor de complimenten!

 

Aanpassing voor leeg:

 

If(

PatternCount(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(code;

"A";"A");"B";"A");"C";"A");"D";"A");"E";"A");"F";"A");"G";"A");"H";"A");"I";"A");"J";"A");"K";"A");"L";"A");"M";"A");"N";"A");"O";"A");"P";"A");"Q";"A");"R";"A");"S";"A");"T";"A");"U";"A");"V";"A");"W";"A");"X";"A");"Y";"A");"Z";"A");"0";"N");"1";"N");"2";"N");"3";"N");"4";"N");"5";"N");"6";"N");"7";"N");"8";"N");"9";"N")

; "ANNNN_NN" )>0;

Middle(code;

Position(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(code;

"A";"A");"B";"A");"C";"A");"D";"A");"E";"A");"F";"A");"G";"A");"H";"A");"I";"A");"J";"A");"K";"A");"L";"A");"M";"A");"N";"A");"O";"A");"P";"A");"Q";"A");"R";"A");"S";"A");"T";"A");"U";"A");"V";"A");"W";"A");"X";"A");"Y";"A");"Z";"A");"0";"N");"1";"N");"2";"N");"3";"N");"4";"N");"5";"N");"6";"N");"7";"N");"8";"N");"9";"N")

; "ANNNN_NN" ; 1; 1)

; 8 )

;"")

 

HTH

Stef

  • 0
Posted

Ik heb ondertussen zelf al gevonden. Dit is de definitieve formule:

 

If(PatternCount(Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(#Varname;

"A";"A");"B";"A");"C";"A");"D";"A");"E";"A");"F";"A");"G";"A");"H";"A");"I";"A");"J";"A");"K";"A");"L";"A");"M";"A");"N";"A");"O";"A");"P";"A");"Q";"A");"R";"A");"S";"A");"T";"A");"U";"A");"V";"A");"W";"A");"X";"A");"Y";"A");"Z";"A");"0";"N");"1";"N");"2";"N");"3";"N");"4";"N");"5";"N");"6";"N");"7";"N");"8";"N");"9";"N")

;"ANNNN_NN")>0;Middle(#Varname;

Position(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(Substitute(Substitute(Substitute(Substitute(

Substitute(#Varname;

"A";"A");"B";"A");"C";"A");"D";"A");"E";"A");"F";"A");"G";"A");"H";"A");"I";"A");"J";"A");"K";"A");"L";"A");"M";"A");"N";"A");"O";"A");"P";"A");"Q";"A");"R";"A");"S";"A");"T";"A");"U";"A");"V";"A");"W";"A");"X";"A");"Y";"A");"Z";"A");"0";"N");"1";"N");"2";"N");"3";"N");"4";"N");"5";"N");"6";"N");"7";"N");"8";"N");"9";"N")

; "ANNNN_NN" ; 1; 1); 8 );"")

Nogmaals bedankt,

Erik

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...