Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

StringRegExp math multi character


  • Please log in to reply
4 replies to this topic

#1 luckyluke

luckyluke

    Wayfarer

  • Active Members
  • Pip
  • 53 posts

Posted 17 May 2012 - 12:07 AM

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







#2 boththose

boththose

    þヨⓡᅷ∈℃⊥

  • Active Members
  • PipPipPipPipPipPip
  • 1,508 posts

Posted 17 May 2012 - 02:16 AM

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

Edited by boththose, 17 May 2012 - 02:17 AM.

Spoiler

#3 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 17 May 2012 - 07:04 PM

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

GeorgeQuestion 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!"

#4 Malkey

Malkey

  • MVPs
  • 1,523 posts

Posted 17 May 2012 - 10:03 PM

A non-array result:-
AutoIt         
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


#5 luckyluke

luckyluke

    Wayfarer

  • Active Members
  • Pip
  • 53 posts

Posted 30 May 2012 - 06:05 AM

it's greate, thanks in advance for this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users