Example text 1
Example text 2
Example text 3
Code: Select all
Text=
(
***********1.2.3************
Example text 1
Example text 2
Example text 3
***********3.2.1************
)
RegExMatch ?
Code: Select all
Text=
(
***********1.2.3************
Example text 1
Example text 2
Example text 3
***********3.2.1************
)
RegExMatch ?
Code: Select all
Clipboard := "", Clipboard := Trim(RegExReplace(Text, "m`a)(^\W.*?(\v+|\Z)| +$)"), "`n")
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Else MsgBox, 64, Result, %Clipboard%
Yes its works , but not quite right, if i have this textmikeyww wrote: ↑13 May 2021, 08:21Code: Select all
Clipboard := "", Clipboard := Trim(RegExReplace(Text, "m`a)(^\W.*?(\v+|\Z)| +$)"), "`n") ClipWait, 0 If ErrorLevel MsgBox, 48, Error, An error occurred while waiting for the clipboard. Else MsgBox, 64, Result, %Clipboard%
Code: Select all
Text=
(
***********1.2.3************
Example text 1
Example text 2
Example text 3
***********3.2.1************
This text doesnt needed 4
This text doesnt needed 5
This text doesnt needed 6
***********4.5.6************
)
Code: Select all
Text=
(
***********1.2.3************
Example text 1
Example text 2
Example text 3
***********3.2.1************
This text doesnt needed 4
This text doesnt needed 5
This text doesnt needed 6
***********4.5.6************
)
RegExMatch(Text, "`am)(^Example text \d+$\R?)+", m)
MsgBox, % m
Not correct, beacuse Example text = unknown value, this will maybe anything textteadrinker wrote: ↑13 May 2021, 08:47Perhaps this one is correct:Code: Select all
Text= ( ***********1.2.3************ Example text 1 Example text 2 Example text 3 ***********3.2.1************ This text doesnt needed 4 This text doesnt needed 5 This text doesnt needed 6 ***********4.5.6************ ) RegExMatch(Text, "`am)(^Example text \d+$\R?)+", m) MsgBox, % m
Code: Select all
Text=
(
***********1.2.3************
asddqwlkajsfdlksaa
eqwijfjzx,mnsdapo
23190-8gdosisahdd
***********3.2.1************
This text doesnt needed 4
This text doesnt needed 5
This text doesnt needed 6
***********4.5.6************
)
Value 1.2.3 maybe whatever, need to get the first section text inside ***RandomValue*** ->some text<- ***RandomValue***boiler wrote: ↑13 May 2021, 08:57@djuga - Your instructions are still incomplete. Do you want to extract the text only after the first section that is marked by a header and before the next section that is marked by a header, or must the header contain 1.2.3? It would again be possible to meet your exact latest example and then you show another example where it doesn't work by your new definition. Also, will there always be a blank line after the header and before the next one?
Code: Select all
Text=
(
***********1.2.3************
asddqwlkajsfdlksaa
eqwijfjzx,mnsdapo
23190-8gdosisahdd
***********3.2.1************
This text doesnt needed 4
This text doesnt needed 5
This text doesnt needed 6
***********4.5.6************
)
RegExMatch(Text, "^\*+\d+\.\d+\.\d+\*+\v*\K.*?(?=\v+\*+\d+\.\d+\.\d+\*+)", m)
MsgBox, % m
My big thx! Thats itboiler wrote: ↑13 May 2021, 09:10Code: Select all
Text= ( ***********1.2.3************ asddqwlkajsfdlksaa eqwijfjzx,mnsdapo 23190-8gdosisahdd ***********3.2.1************ This text doesnt needed 4 This text doesnt needed 5 This text doesnt needed 6 ***********4.5.6************ ) RegExMatch(Text, "^\*+\d+\.\d+\.\d+\*+\v*\K.*?(?=\v+\*+\d+\.\d+\.\d+\*+)", m) MsgBox, % m
Code: Select all
RegExMatch(Text, "\n\n\K.+?(?=\n\n)", new)
Send {Text}%new%
Yes this also worksmikeyww wrote: ↑13 May 2021, 09:13Here's mine-- perhaps not as accurate as @boiler's.
Code: Select all
RegExMatch(Text, "\n\n\K.+?(?=\n\n)", new) Send {Text}%new%
Code: Select all
Text=
(
***********1.2.3************
Example text 1
Example text 2
Example text 3
***********3.2.1************
Bla, bla
Bla, bla
***********4.5.6************
Example text 1
Example text 2
Example text 3
***********1.2.3************
)
Templ := "(\*+?[^*]+\*+?\R+)"
Templ2 := "\K(.*?)"
while pos := RegExMatch(Text, "s)" Templ Templ2 Templ, m, A_Index=1?1:pos+StrLen(m))
MsgBox, % m2
Code: Select all
Text=
(
***********1.2.3************
asddqwlkajsfdlksaa
eqwijfjzx,mnsdapo
23190-8gdosisahdd
***********3.2.1************
This text doesnt needed 4
This text doesnt needed 5
This text doesnt needed 6
***********4.5.6************
)
Your way is perfect, but how about fileread ?boiler wrote: ↑13 May 2021, 09:19I thought about the approach with just checking the newlines but was thinking you might then say it doesn't work with this:Code: Select all
Text= ( ***********1.2.3************ asddqwlkajsfdlksaa eqwijfjzx,mnsdapo 23190-8gdosisahdd ***********3.2.1************ This text doesnt needed 4 This text doesnt needed 5 This text doesnt needed 6 ***********4.5.6************ )
Code: Select all
FileRead, Text, my file.txt
I know it , but its doesnt work if you read data from fileboiler wrote: ↑13 May 2021, 09:29Instead of assigning the text to Text, replace it with:Code: Select all
FileRead, Text, my file.txt
Code: Select all
FileRead, Text, %A_ScriptDir%\test.txt
RegExMatch(Text, "s)\*\v+\K.+?(?=\v+\*)", new)
SendInput {Text}%new%
This worksmikeyww wrote: ↑13 May 2021, 09:34Code: Select all
FileRead, Text, %A_ScriptDir%\test.txt RegExMatch(Text, "s)\*\v+\K.+?(?=\v+\*)", new) SendInput {Text}%new%
Just put s) in front:
Code: Select all
RegExMatch(Text, "s)^\*+\d+\.\d+\.\d+\*+\v*\K.*?(?=\v+\*+\d+\.\d+\.\d+\*+)", new)
Users browsing this forum: inseption86, peter_ahk, william_ahk and 172 guests