GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   find and replace links in a large text file (https://gfy.com/showthread.php?t=912206)

d-null 06-23-2009 03:34 PM

find and replace links in a large text file
 
is there a utility, or is it possible with notepad++ or any other of the popular code editors to do a search and replace with wildcards?


eg. say you have a large text file, that is scattered with a bunch of <a href... type of links, but they are all different as far as text and url's, I would like to use a * wildcard to be able to search for all occurences of any type of link and replace it with something else


any ideas?

woj 06-23-2009 03:35 PM

regexp FTW

d-null 06-23-2009 03:44 PM

Quote:

Originally Posted by woj (Post 15990469)
regexp FTW

ok, I'm seeing it, now just have to learn the syntax :P

fris 06-23-2009 06:28 PM

Code:

sed 's/old/new/g' input.txt > output.txt

d-null 06-23-2009 06:33 PM

Quote:

Originally Posted by fris (Post 15990865)
Code:

sed 's/old/new/g' input.txt > output.txt

interesting, I need it to do some regexp matching though, the old url's are all different, and I want to match them all with one command

GrouchyAdmin 06-23-2009 06:35 PM

wildcard to match any type of link? Sure!

Code:

/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/i
Enjoy.

d-null 06-23-2009 06:41 PM

Quote:

Originally Posted by GrouchyAdmin (Post 15990885)
wildcard to match any type of link? Sure!

Code:

/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/i
Enjoy.

thanks Grouchy, you saved me some time, I'll try it out soon :thumbsup

d-null 06-23-2009 06:47 PM

edit: not working for some reason, is the code right and I am doing something wrong? using regexp search but not matching

96ukssob 06-23-2009 06:50 PM

download textpad, it works great.

press F8, then use .*. as the wild card.

GrouchyAdmin 06-23-2009 06:59 PM

The above is Perl Regex, not "universal" regex.

d-null 06-23-2009 07:01 PM

Quote:

Originally Posted by GrouchyAdmin (Post 15990925)
The above is Perl Regex, not "universal" regex.

oh ok, I was trying to use it with notepad++ and no luck with that

GrouchyAdmin 06-23-2009 07:02 PM

Quote:

Originally Posted by d-null (Post 15990931)
oh ok, I was trying to use it with notepad++ and no luck with that

I just use TextPad for that kind of shit when on Windows It usually takes normal, or semi-perl regex just fine. Sorry, never used NP++.

d-null 06-23-2009 07:05 PM

found the answer:


Code:

<a href="[^"]+">[^<]+</a>

thanks for the help, it was interesting, maybe this thread will help someone else too


All times are GMT -7. The time now is 08:08 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123