/    Sign up×
Community /Pin to ProfileBookmark

Shortening a list of regexp’s

Is there any way to make shorten this code here? Like… make it do all of that in just a couple splits?

as = fixmsg.match(/<a href=”/i);
if (as != “null”) {
as2 = fixmsg.split(/<a href=”/i);
as3 = as2.join(“”);
as4 = as3.split(/</a>/i);
for (i=0; i<as4.length; i++) {
as6 = as4[i].split(/>.{0,}/i);
as7 = as6.join(“”);
as8 = as7.split(/”/i);
as9 = as8.join(“”);
as10 = as9.split(/target=_blank/i);
as11 = as10.join(“”);
as12 = as11.split(/mailto:/i);
as13 = as12.join(“”);
as14[i] = as13;
}
as5 = as14.join(“”);
}

Basically what I’m trying to do is to cut down all of the a tags in the fixmsg string, and only show the actual link, not including the <a href> stuff.

Any help would be greatly appreciated. ?

And… if there is any chance that anyone would know a regexp for getting rid of any HTML tags?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorOct 01.2007 — Why not simply return the attribute's value?
<i>
</i>&lt;a href="http://www.webdeveloper.com" onclick="alert(this.getAttribute('href'));return false)"&gt;webdev&lt;/a&gt;
Copy linkTweet thisAlerts:
@ChipChampauthorOct 01.2007 — Lol! Didn't even think about that... But then I'd still need to get rid of the tags... So, do you know any way to get rid of all the HTML tags?
Copy linkTweet thisAlerts:
@KorOct 02.2007 — What, in fact, is the general picture? What do you intend to do?
Copy linkTweet thisAlerts:
@ChipChampauthorOct 02.2007 — Get rid of all of the HTML tags..
Copy linkTweet thisAlerts:
@Orc_ScorcherOct 02.2007 — For example, with the input [code=html]<p><a href="example.html">click here.</a></p>[/code] you want the output [code=html]<p>example.html</p>[/code]? Then try<i>
</i>as5 = fixmsg.replace(/&lt;a.*?href="(.*?)".*?/a&gt;/g, "$1")
Copy linkTweet thisAlerts:
@ChipChampauthorOct 02.2007 — Yeah, thanks! I'll try using that. ?
×

Success!

Help @ChipChamp spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...