My updated code for multi-word cities:
--City & Post Code extract from a string
{Assumptions:
City name follows post code and it's at the right end of the string
First character of all city-name words is alpha
Post code is one "word" - no spaces, hyphens are ok
First character of post code is numeric
This won't work for Canadian post codes formatted ANA NAN, sorry Quebec :)
}
CLS
SET VAR +
vCity TEXT = NULL, +
vPostCode TEXT = NULL
SET VAR VADRCHANT TEXT = +
'Mobil Home Rideau 12 Parc de la Landette 85190 VENANSAULT AU NORD'
--Replace spaces with commas so parsing functions work
SET VAR VADRCHANT2 = (SRPL(.VADRCHANT,' ',',',0))
--Get length of VADRCHANT in number of words
SET VAR vCount = (ITEMCNT(.VADRCHANT2))
--Start at the right end and extract last word, assuming it's a city name
SET VAR vCity = (SSUB(.VADRCHANT2,.vCount))
--Move left one word
SET VAR vCount = (.vCount - 1)
--Iterate left a word at a time till we get a numeric, i.e. post code
WHILE vPostCode IS NULL THEN
--if this word begins with a number, it's a post code
IF (ISDIGIT((SSUB(.VADRCHANT2,.vCount)))) = 1 THEN
SET VAR vPostCode = ((SSUB(.VADRCHANT2,.vCount))) --this will exit
WHILE loop
ELSE
--If not numeric, prepend it to existing vCity
SET VAR vCity = ((SSUB(.VADRCHANT2,(.vCount)) & .vCity ))
ENDIF
--Move left one word
SET VAR vCount = (.vCount - 1)
ENDWHILE
SHOW VAR v%
RETURN
On 1/28/2022 2:37 AM, Jean-Marc Massé wrote:
Bonjour à tous,
Dans une table de coordonnées de clients j’ai un champ NOTE
« ADRCHANT » dans lequel figure l’adresse complète du client comme la
variable jointe
SET VAR VADRCHANT TEXT = "Mobil Home Rideau 12 Parc de la Landette
*85190* *VENANSAULT*"
Pourriez vous me dire comment on peut extraire d’un coté le code
postal « *85190* » dans une variable distincte
Et d’autre part la ville « *VENANSAULT* » dans une autre variable ?
Merci d’avance pour votre aide !
Traduction Google :
Hello everyone,
In a table of customer details I have a field NOTE "ADRCHANT" in which
appears the complete address of the customer as the attached variable
SET VAR VADRCHANT TEXT = "Mobile Home Rideau 12 Parc de la Landette
85190 VENANSAULT"
Could you tell me how we can extract on one side the postal code
"*85190*" in a separate variable
And on the other hand the city "*VENANSAULT*" in another variable?
Thank you in advance for your help !
Best regards,
------------------------------------------------------------------------
*Jean-Marc Massé *(mobile : 06.08.82.80.86)
Sté MCS 85510 ROCHETREJOUX (France)
------------------------------------------------------------------------
--
For group guidelines, visit
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google
Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/rbase-l/3549e19b3ab14f7dbcc5500f9aa9ca67%40masse-charpente.fr
<https://groups.google.com/d/msgid/rbase-l/3549e19b3ab14f7dbcc5500f9aa9ca67%40masse-charpente.fr?utm_medium=email&utm_source=footer>.
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
For group guidelines, visit
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/rbase-l/b5550ac5-483c-62d6-f227-217f28399699%40wi.rr.com.