Anuragravi Posted July 14, 2018 Posted July 14, 2018 (edited) Hi All i am new to Autoit, I want to extract all ip address in array format from this string. please help #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <array.au3> $str = "ghg shjsja 192.168.1.2 hbkjNKKSJKKN HKJCBKJLKKL 12.15.14.45 KJBKJABCKBNDKQ KHBKJABCKJQDH 1.1.1.1" $copy = StringRegExp($str,"((\d{1,3}\.){3}\d{1,3})",$STR_REGEXPARRAYMATCH) MsgBox(0,"",$copy[0]) Edited July 14, 2018 by Anuragravi
TheXman Posted July 14, 2018 Posted July 14, 2018 (edited) Here's one of several ways to do it: #include <Constants.au3> #include <array.au3> example() Func example() Local $s = "ghg shjsja 192.168.1.2 hbkjNKKSJKKN HKJCBKJLKKL 12.15.14.45 KJBKJABCKBNDKQ KHBKJABCKJQDH 1.1.1.1" Local $aIP = StringRegExp($s,"(?:\d{1,3}\.){3}\d{1,3}",$STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay($aIP) EndFunc Edited July 14, 2018 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
iamtheky Posted July 14, 2018 Posted July 14, 2018 also, if it's always "string space string space (target)" #include <array.au3> example() Func example() Local $s = "ghg shjsja 192.168.1.2 hbkjNKKSJKKN HKJCBKJLKKL 12.15.14.45 KJBKJABCKBNDKQ KHBKJABCKJQDH 1.1.1.1" $a = stringregexp($s , ".+?\s.+?\s(.+?)(?:\s|\z)" , 3) _ArrayDisplay($a) EndFunc ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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