Jump to content

StringRegExp get the names of sites


Recommended Posts

I need the names of sites in a file

c0eef6a8c648414d8280a5be71e8a857.jpg

 

my experiment has failed :doh:

#Include <Array.au3>
$text = FileRead("test.txt")
$aStr = StringRegExp($text, '(?:http|https)s?[^"\r\n]+(.com|.org|.com.tr|.net).*', 3)
_ArrayDisplay($aStr)

or StringRegExpReplace

#Include <Array.au3>
$text = FileRead("test.txt")
$aStr = StringRegExpReplace($text, '(?:http|https)s?[^"\r\n]+(.com|.org|.com.tr|.net).*', '$1')
_ArrayDisplay($aStr)

Edit: or pattern

$ReadString = FileRead("test.txt")
$ReadString = StringReplace($ReadString,@CR,'')
$pattern = '(http://|\.https://|\.www|\.com|\.net|\.org|\.info|\.biz|\.eu|\.fr|\.ch|\.kr|\.edu|\.tr)(.*)'
$ReplaceString = StringRegExpReplace($ReadString, $pattern, "")
   ConsoleWrite(($ReplaceString) & @CRLF)

 

Edited by youtuber
Link to comment
Share on other sites

no regex needed, just two splits

#include<array.au3>

;~ $string = "http://test.1sthostname.com/whatever"
;~ $string = "http://test2.2ndhostname2.net"
$string = "http://3test.3rdhostname.info/whomever"
;~ $string = "http://4test.hostnumber4.xxx/wtfever"
;~ $string = "http://test.hostname.google/TLDwtfbbq/forever"

$aStringSplit1 = stringsplit($string , "/" , 2)
_ArrayDelete($aStringSplit1 , ubound($aStringSplit1) - 1)
$aStringSplit2 = stringsplit($aStringSplit1[2] , "." , 2)
_ArrayDelete($aStringSplit2 , ubound($aStringSplit2) - 1)

msgbox(0 , '' , _ArrayToString($aStringSplit2 , "."))

 

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

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...