DannyJ Posted June 23, 2020 Posted June 23, 2020 I have city names and adresses like that: London XV. Small Street 3. Bukarest V. Big Street 4. Kijev New Street 55. Okland VIII. olden street 33. Sydney Small street 44. All city names are one word names, but some of them has a district code. Because of that I am not able to Split the city name from adress correctly. If a city has district code it's a roman number and it ends with a dot. I want trim that way: London XV. |Small Street 3. Bukarest V. |Big Street 4. Kijev |New Street 55. Okland VIII. |olden street 33. Sydney |Small street 44. | sign not necessarry I only want to trim this text Thy in advance.
Developers Jos Posted June 23, 2020 Developers Posted June 23, 2020 Are the district numbers always Roman numbers? IF that is the case you can do it with a RegEx. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Zedna Posted June 23, 2020 Posted June 23, 2020 (edited) ;~ London XV. Small Street 3 ;~ Bukarest V. Big Street 4 ;~ Kijev New Street 55 ;~ Okland VIII. olden street 33 ;~ Sydney Small street 44 $text = 'Okland VIII. olden street 33' $i = StringInStr($text,'.',1) ; first dot If $i > 0 Then ; remove VIII. $j = StringInStr($text,' ',1,-1,$i-1) ; first space to the left from dot If $j > 0 Then $text = StringLeft($text,$j-1) & StringMid($text,$i+1) EndIf ConsoleWrite($text&@CRLF) $k = StringInStr($text,' ',1) ; split by first space If $i > 0 Then $city = StringLeft($text,$k-1) $street = StringMid($text,$k+1) ConsoleWrite('city: '&$city&@CRLF) ConsoleWrite('street: '&$street&@CRLF) EndIf Edited June 23, 2020 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Developers Jos Posted June 23, 2020 Developers Posted June 23, 2020 I think this is never going to be an easy one as one other issue could be when the City name consists of multiple words like "New York". SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Musashi Posted June 23, 2020 Posted June 23, 2020 1 hour ago, Jos said: I think this is never going to be an easy one as one other issue could be when the City name consists of multiple words like "New York". That's what I thought too . There are most likely cases that cannot be accurately mapped from the available data. 2 hours ago, DannyJ said: I have city names and adresses like that: What is the source of these data? Is it possible to have a separation of the elements already at the creation process? "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
mikell Posted June 23, 2020 Posted June 23, 2020 5 hours ago, DannyJ said: All city names are one word names Assuming that this assertion is always true, here is a possible way #Include <Array.au3> $txt = "London XV. Small Street 3." & @crlf & _ "Bukarest V. Big Street 4." & @crlf & _ "Kijev New Street 55." & @crlf & _ "Okland VIII. olden street 33." & @crlf & _ "Sydney Small street 44." $r = StringRegExpReplace($txt, '(?m)^\w+(\h+[A-Z]+\.)?\K(\h+)', "|") Local $a[0][2] _ArrayAdd($a, $r) _ArrayDisplay($a)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now