Sign in to follow this  
Followers 0
leuce

Remove all but XML style tags from text

3 posts in this topic

G'day everyone

Here's what I want to do:

Turn this: <a0>This is a <a0/><b1>house<b1/>.

In to this: <a0><a0/><b1><b1/>

A couple of months ago I asked a similar question to this one, here, and the solution I got removing XML style tags here worked fine.

But this time I want to do the opposite, and after struggling several minutes with various regex strings I must admit that I do not understand how AutoIt's regex functions work. As far as my mind can stretch, this should work:

$j = StringRegExpReplace($i, '^(<[a-z,0-9,\\]*>)', '')

...but it doesn't -- in fact, it removes the first XML tag.

Can anyone please put me out of my misery and tell me what the correct regex syntax for this would be?

Thanks

Samuel

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try this:

#include <array.au3>
$i = "<a0>This is a <a0/><b1>house<b1/>."
$array = StringRegExp($i, '(<[a-z][0-9][/]{0,1}>)', 3)
$j = _ArrayToString ( $array, "")
MsgBox(0,"Info",$j)oÝ÷ ØÜjDz¢ì­éh¢H§ú+k²¶Þ¶êçë-ªê-N¬Æ¡¢ëªê-bjwhÛaÌÉ«­¢+ØÀÌØí¤ôÅÕ½Ðì±ÐíÀÐíQ¡¥Ì¥Ì±ÐíÀ¼Ðì±ÐíÄÐí¡½ÕͱÐíļÐì¸ÅÕ½Ðì(ÀÌØíÍÑÉ¥¹ôMÑÉ¥¹IáÁIÁ± ÀÌØí¤°Ìäì ±ÐímµéulÀ´åul½uìÀ°ÅôÐì¤Ìäì°ÅÕ½ÐìÅÕ½Ðì¤)5Í ½à À°ÅÕ½Ðí%¹¼ÅÕ½Ðì°ÀÌØíÍÑÉ¥¹¤

The Kandie Man ;-)

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
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
Sign in to follow this  
Followers 0