Jump to content

Recommended Posts

Posted

Hello all

I want to extract a string from text like this:

<pre class="bbcode_code" style="height:372px;">
186.93.6.99:8080
186.94.24.12:8080
187.0.116.173:3128 name1
187.0.222.167:3128
202.47.88.65:3128</pre>

i want to extract the string with this format string.string.string.string:string, for this ex i want this:

186.93.6.99:8080
186.94.24.12:8080
187.0.116.173:3128
187.0.222.167:3128
202.47.88.65:3128

i've try this code

$b = StringRegExp($a, '.*..*..*..*:.*', 3)

but it's not working

Please help

Posted (edited)

stringregexp($a , "(d+.d+.d+.d+:d+)" , 3)

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Posted

or

StringRegExp($a, "d+[d.]+:d+", 3)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

A non-array result:-

Local $sTestString = '<pre class="bbcode_code" style="height:372px;">' & @CRLF & _
        '186.93.6.99:8080' & @CRLF & _
        'Hi 186.94.24.12:8080' & @CRLF & _
        'There187.0.116.173:3128 name1' & @CRLF & _
        'Hello world!' & @CRLF & _
        '187.0.222.167:3128' & @CRLF & _
        '202.47.88.65:3128</pre>'

;Local $aString = StringTrimRight(StringRegExpReplace($sTestString, "(?s)(?:.*?(d+.d+.d+.d+:d+)(.*?v+|.*?$))", "$1" & @LF), 1) ; or
Local $aString = StringTrimRight(StringRegExpReplace($sTestString, "(?s)(?:.*?(d+[d.]+:d+)(.*?v+|.*?$))", "$1" & @LF), 1)      ; or
;Local $aString = StringTrimRight(StringRegExpReplace($sTestString, "(?s)(?:.*?(d+(.d+){3}:d+)(.*?v+|.*?$))", "$1" & @LF), 1)

ConsoleWrite($aString & @LF)

#cs
All three (3) examples return:-
186.93.6.99:8080
186.94.24.12:8080
187.0.116.173:3128
187.0.222.167:3128
202.47.88.65:3128
#ce
  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...