michaelslamet Posted April 7, 2014 Posted April 7, 2014 (edited) $str = '08121901000 - 022 99621221 - www.adv08.com</div><!--description-->' & @CRLF & _ 'call: 08 55555 6111 (Dadan)</div><!--description-->' & @CRLF & _ '<img src="/getattachment/9630832c-3d4e-4e5b-af83-ee8bb6e9dbad/Show.aspx?maxSideSize=60" alt="Bemper Mitsubishi Pajero 2002"/></div><!--slide-thumbnail-->' & @CRLF & _ '<a href="/Asesoris-car/Aksesoris-other/Bemper-Mitsubishi-Pajero-2002-512066" target="_blank">Bemper Mitsubishi Pajero 2002</a><br />Bemper Mitsubishi Pajero 2002 4x4. Import from Australia, brand new, eks stock, call Raymond 0812711451</div><!--description-->' & @CRLF & _ 'Joe: 0878 6131 7111' & @CRLF & _ 'Text Me : 0822 8124 8624' & @CRLF & _ '081251136118(james)' & @CRLF & _ '7123408,081288778899' & @CRLF & _ '022 99621221,08121901012 - www.adv808.com</div><!--description-->' & @CRLF & _ '99621081,08111901112 - www.adv808.com</div><!--description-->' & @CRLF & _ 'For more info, please call 081233666201 / 081731161201' & @CRLF & _ 'For more info, please call 081233666201' & @CRLF & _ '<div class="titl listtitl"><a href="/car/acce-Others/VIMAX-PILL-ORIGINAL-(4)">VIMAX PILL ORIGINAL PERMANENT (081126747616)</a></div>' & @CRLF & _ 'there is nothing to grab here 08klajsa212222' & @CRLF & _ 'there is no valid pattern to grab here because length is 9 081123456' & @CRLF I would like to get number that start with "08" and length between 10~12, eg: 08121901000 from "08121901000 - 022 99621221 - www.adv08.com</div><!--description-->" 08555556111 from "call: 08 55555 6111 (Dadan)</div><!--description-->" 0812711451 from "<a href="/Asesoris-car/Aksesoris-other/Bemper-Mitsubishi-Pajero-2002-512066" target="_blank">Bemper Mitsubishi Pajero 2002</a><br />Bemper Mitsubishi Pajero 2002 4x4. Import from Australia, brand new, eks stock, call Raymond 0812711451</div><!--description-->" 087861317111 from "Joe: 0878 6131 7111" & @CRLF 082281248624 from "Text Me : 0822 8124 8624" & @CRLF 081251136118 from "081251136118(james)" & @CRLF 081288778899 from "7123408,081288778899" & @CRLF 08121901012 from "022 99621221,08121901012 - www.adv808.com</div><!--description-->" & @CRLF 081233666201 and 081731161201 from "For more info, please call 081233666201 / 081731161201" & @CRLF 081233666201 from "For more info, please call 081233666201" & @CRLF 081126747616 from "<div class="titl listtitl"><a href="/car/acce-Others/VIMAX-PILL-ORIGINAL-(4)">VIMAX PILL ORIGINAL PERMANENT (081126747616)</a></div>" & @CRLF I think this is a very difficult RegExp pattern, isn't it? Or how to grab that without RegExp? Thanks Edited April 7, 2014 by michaelslamet
iamtheky Posted April 7, 2014 Posted April 7, 2014 (edited) _Test("08121901000 - 022 99621221 - www.adv08.com</div><!--description-->") _Test("call: 08 55555 6111 (Dadan)</div><!--description-->") _Test('<a href="/Asesoris-car/Aksesoris-other/Bemper-Mitsubishi-Pajero-2002-512066" target="_blank">Bemper Mitsubishi Pajero 2002</a><br />Bemper Mitsubishi Pajero 2002 4x4. Import from Australia, brand new, eks stock, call Raymond 0812711451</div><!--description-->') _Test("Joe: 0878 6131 7111" & @CRLF) _Test("Text Me : 0822 8124 8624" & @CRLF) _Test("081251136118(james)" & @CRLF) _Test("7123408,081288778899" & @CRLF) _Test("022 99621221,08121901012 - www.adv808.com</div><!--description-->" & @CRLF) _Test("For more info, please call 081233666201 / 081731161201" & @CRLF) _Test("For more info, please call 081233666201" & @CRLF) _Test('<div class="titl listtitl"><a href="/car/acce-Others/VIMAX-PILL-ORIGINAL-(4)">VIMAX PILL ORIGINAL PERMANENT (081126747616)</a></div>' & @CRLF) Func _Test($StringTst) $string = stringstripws($StringTst , 8) $aString = stringregexp($string , "08\d+" , 3) For $i = 0 to ubound($aString) - 1 If StringLen($aString[$i]) > 9 And StringLen($aString[$i]) < 13 Then msgbox (0, '' , $aString[$i]) next EndFunc Edited April 7, 2014 by boththose michaelslamet 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Moderators Melba23 Posted April 7, 2014 Moderators Posted April 7, 2014 michaelslamet,This seems to work: #include <Array.au3> Global $aString[] = ["08121901000 - 022 99621221 - www.adv08.com</div><!--description-->", _ "call: 08 55555 6111 (Dadan)</div><!--description-->", _ '<a href="/Asesoris-car/Aksesoris-other/Bemper-Mitsubishi-Pajero-2002-512066" target="_blank">Bemper Mitsubishi Pajero 2002</a><br />Bemper Mitsubishi Pajero 2002 4x4. Import from Australia, brand new, eks stock, call Raymond 0812711451</div><!--description-->', _ "Joe: 0878 6131 7111", _ "Text Me : 0822 8124 8624", _ "081251136118(james)", _ "7123408,081288778899", _ "022 99621221,08121901012 - www.adv808.com</div><!--description-->", _ "For more info, please call 081233666201 / 081731161201", _ "For more info, please call 081233666201", _ '<div class="titl listtitl"><a href="/car/acce-Others/VIMAX-PILL-ORIGINAL-(4)">VIMAX PILL ORIGINAL PERMANENT (081126747616)</a></div>'] For $i = 0 To UBound($aString) - 1 ; Strip all spaces to make sure the digits are sequential $aRet = StringRegExp(StringStripWS($aString[$i], 8), "(08\d{8,10})", 3) _ArrayDisplay($aRet, "", Default, 8) NextSRE decode:(08\d{8,10}) - Capture any string beginning with 08 and followed by 8 to 10 other digits 3 - Create an array of all instancesDoes that do what you want? M23 michaelslamet 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Solution mikell Posted April 7, 2014 Solution Posted April 7, 2014 (edited) #include <Array.au3> $str = '08121901000 - 022 99621221 - www.adv08.com</div><!--description-->' & @CRLF & _ 'call: 08 55555 6111 (Dadan)</div><!--description-->' & @CRLF & _ '<img src="/getattachment/9630832c-3d4e-4e5b-af83-ee8bb6e9dbad/Show.aspx?maxSideSize=60" alt="Bemper Mitsubishi Pajero 2002"/></div><!--slide-thumbnail-->' & @CRLF & _ '<a href="/Asesoris-car/Aksesoris-other/Bemper-Mitsubishi-Pajero-2002-512066" target="_blank">Bemper Mitsubishi Pajero 2002</a><br />Bemper Mitsubishi Pajero 2002 4x4. Import from Australia, brand new, eks stock, call Raymond 0812711451</div><!--description-->' & @CRLF & _ 'Joe: 0878 6131 7111' & @CRLF & _ 'Text Me : 0822 8124 8624' & @CRLF & _ '081251136118(james)' & @CRLF & _ '7123408,081288778899' & @CRLF & _ '022 99621221,08121901012 - www.adv808.com</div><!--description-->' & @CRLF & _ '99621081,08111901112 - www.adv808.com</div><!--description-->' & @CRLF & _ 'For more info, please call 081233666201 / 081731161201' & @CRLF & _ 'For more info, please call 081233666201' & @CRLF & _ '<div class="titl listtitl"><a href="/car/acce-Others/VIMAX-PILL-ORIGINAL-(4)">VIMAX PILL ORIGINAL PERMANENT (081126747616)</a></div>' & @CRLF & _ 'there is nothing to grab here 08klajsa212222' & @CRLF & _ 'there is no valid pattern to grab here because length is 9 081123456' & @CRLF $aRet = StringRegExp(StringStripWS($str, 8), "08\d{8,10}", 3) _ArrayDisplay($aRet) The results are slightly different than Melba's because this code uses the string from your first post Edited April 7, 2014 by mikell michaelslamet 1
michaelslamet Posted April 8, 2014 Author Posted April 8, 2014 @boththose, @Melba, @mikell: wonderful, works as expected! I'm going to make slight modification since I found some other patterns as well. Thank you so much
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