Can anyone help me to Extract numbers between parentheses on google datasheet?
I have theese:
Bacacheri, Curitiba (82515280), Paraná
I want to extract the Number 82515280
Annd need to extract
"Bacacheri" First string before comma
"Curitiba" Second string before comma but wihtout (82515280)
"Paraná", Third string after commas
How too extract numbers between parentheses and strings comma separated Topic is solved
Re: How too extract numbers between parentheses and strings comma separated
Hallo,
try:
try:
Code: Select all
Text = Bacacheri, Curitiba (82515280), Paraná
Loop, Parse, Text, CSV
{
Text%A_Index% := Trim(RegExReplace(A_LoopField, "[0-9()]",""))
Number%A_Index% := Trim(RegExReplace(A_LoopField, "[^0-9]",""))
}
MsgBox, % "Text1: " Text1
MsgBox, % "Text2: " Text2
MsgBox, % "Number2: " Number2
MsgBox, % "Text3: " Text3
Re: How too extract numbers between parentheses and strings comma separated
And replace Text = Bacacheri, Curitiba (82515280), Paraná with Text = ClipBoard when you're on the data sheet. You will have to copy to cliboard.
I am your average ahk newbie. Just.. a tat more cute.
Re: How too extract numbers between parentheses and strings comma separated
Non regex example for something different:
Code: Select all
String := "Bacacheri, Curitiba (82515280), Paraná"
Loop, Parse, String, CSV, %A_Space%
{
if (A_Index = 1)
Col1 := A_LoopField
else if (A_Index = 2)
Loop, Parse, A_LoopField, %A_Space%,()
(A_Index = 1) ? Col2 := A_LoopField : Col3 := A_LoopField
else
Col4 := A_LoopField
}
MsgBox % Col1 . "`n"
. Col2 . "`n"
. Col3 . "`n"
. Col4
Re: How too extract numbers between parentheses and strings comma separated
Another way:
Code: Select all
Text = Bacacheri, Curitiba (82515280), Paraná
while RegExMatch(Text, "O)[\d\w\p{L}]+", w, A_Index = 1 ? 1 : w.Pos + w.Len)
str .= w.value "`n"
msgbox % str
Last edited by Odlanir on 17 Mar 2018, 04:47, edited 1 time in total.
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: How too extract numbers between parentheses and strings comma separated Topic is solved
Two ideas.
Code: Select all
q:: ;split text
vText := "Bacacheri, Curitiba (82515280), Paraná"
RegExMatch(vText, "O)^(.*?), (.*?) \((\d*)\), (.*)$", oMatch)
MsgBox, % oMatch.1 "|" oMatch.2 "|" oMatch.3 "|" oMatch.4
;using StrSplit
vText := "Bacacheri, Curitiba (82515280), Paraná"
oArray := StrSplit(vText, ", ")
MsgBox, % oArray.1 "|" oArray.2 "|" oArray.3
RegExMatch(oArray.2, "O)^(.*?) \((\d*)\)$", oMatch)
MsgBox, % oArray.1 "|" oMatch.1 "|" oMatch.2 "|" oArray.3
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
- SpeedMaster
- Posts: 494
- Joined: 12 Nov 2016, 16:09
Re: How too extract numbers between parentheses and strings comma separated
strsplit() only:
Code: Select all
String :="Bacacheri, Curitiba (82515280), Paraná"
col:=strsplit(string, a_space , "`,()")
MsgBox % Col.1 . "`n"
. Col.2 . "`n"
. Col.3 . "`n"
. Col.4
Re: How too extract numbers between parentheses and strings comma separated
@ SpeedMaster
Another attempt ...
Another attempt ...
Code: Select all
test := "Bacacheri, Curitiba (82515280), Paraná"
Col := StrSplit(StrReplace(StrReplace(test,"(",","),")",","),",", " ")
MsgBox % Col[1] " " Col[2] " " Col[5]
Re: How too extract numbers between parentheses and strings comma separated
Thank you very much, all ways worked, ill choose the best for me right now
Who is online
Users browsing this forum: Google [Bot], Rohwedder and 246 guests