[Xerte] how to strip out a specific string?

Julian Tenney Julian.Tenney at nottingham.ac.uk
Fri Apr 17 13:52:33 BST 2009


The g needs to be in quotes for the global flag.

 

This works for me:

 

text_item = "fred was here";

my_exp = new RegExp("fred",'g');

new_string = text_item.replace(my_exp, "dave");

 

debug(new_string);

 

 

From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: Friday, April 17, 2009 1:49 PM
To: Xerte list
Subject: RE: [Xerte] how to strip out a specific string?

 


More likely PEBKAC.

"Problem Exists Between Keyboard And Chair"

text_item = "fred was here";
my_exp = new RegExp("fred",g);
new_string = text_item.replace(my_exp, "dave");

Nothing happens, or in some variations I get "Null" in the debug trace.





________________________________

Subject: RE: [Xerte] how to strip out a specific string?
Date: Fri, 17 Apr 2009 13:23:31 +0100
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk

I am a great fan of the saying 'if you have a problem that is best
solved by regular expressions, then you have two problems'.

 

What were you trying to do again?

 

From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: Friday, April 17, 2009 12:52 PM
To: Xerte list
Subject: RE: [Xerte] how to strip out a specific string?

 



I tried a whole whack of variations and could not come up with a
combination to get it to work. :-/
The docs at the authors homepage had no sample code snippets, and the
example .fla code of course would not transfer.

The OP never did say how he resolved, so I just dropped it.

________________________________

Subject: RE: [Xerte] how to strip out a specific string?
Date: Fri, 17 Apr 2009 12:19:10 +0100
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk

In Xerte the replace method is added to the String class, so it's

 

myString.replace(myRegExp, 'replaceString');

 

From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: Monday, April 13, 2009 2:17 AM
To: Xerte list
Subject: RE: [Xerte] how to strip out a specific string?

 



I could be imagining things, but I thought Julian just posted something
about Regular Expressions now being supported.

If that is true, then this would work:

new_xml = replace(original_xml, /the_string_here/g, "");

the /g at the end if the string parameter means "global", so it would
replace all the instances of that URL with "".

Dave

________________________________

From: ronm at mitchellmedia.co.uk
To: xerte at lists.nottingham.ac.uk
Subject: Re: [Xerte] how to strip out a specific string?
Date: Sun, 12 Apr 2009 20:19:55 +0100

Cheers Dave that's very helpful - I'll give that a try.

 

On 12 Apr 2009, at 19:35, Dave Burnett wrote:

	 

	
	It actually does have a closing tag: />
	
	XML shorthands the closing tag to save characters when all the
info is contained in the attributes, i.e. there is no actual value
between the tags.
	
	<name>jamesclay (James Clay)</name> //no attributes, data
between tags
	
	
	<link type="text/html" rel="alternate"
href="http://twitter.com/jamesclay/statuses/1483252089"/>
	
	//all data in opening tag attributes, no explicit closing tag,
just />
	
	
	So if you know the format you show below would be consistent,
you could key on that "/>" as the end of the string and RFind (reverse
find) back to the first "/" you hit.
	
	That should isolate the actual picture name/format.
	
	Dave

	
________________________________


	From: ronm at mitchellmedia.co.uk
	To: xerte at lists.nottingham.ac.uk
	Date: Sun, 12 Apr 2009 19:22:22 +0100
	Subject: [Xerte] how to strip out a specific string?

	Hi all

	I've been experimenting with the new module method of creating
templates and have created a couple of new templates optimised for a
specific purpose which I'll happily share with the community once
complete. One is an optimised  view of twitter feeds but unless I'm
mistaken it seems like the xml isn't complete for some reason. I can
pick up and display the text and links etc ok but I can't work out how
to access the profile pics. Here's an example entry...

	 

	<entry>

	    <id>tag:search.twitter.com,2005:1483252089</id>

	    <published>2009-04-09T12:59:26Z</published>

	    <link type="text/html" rel="alternate"
href="http://twitter.com/jamesclay/statuses/1483252089"/>

	    <title>@ronm123 I meant in a browser, via a second projector
probably.</title>

	    <content type="html">&lt;a
href="http://twitter.com/ronm123"&gt;@ronm123&lt;/a&gt; I meant in a
browser, via a second projector probably.</content>

	    <updated>2009-04-09T12:59:26Z</updated>

	    <link type="image/png" rel="image"
href="http://s3.amazonaws.com/twitter_production/profile_images/96243182
/Photo14_normal.jpg"/>

	    <twitter:source>&lt;a
href="http://twitter.com/"&gt;web&lt;/a&gt;</twitter:source>

	    <author>

	      <name>jamesclay (James Clay)</name>

	      <uri>http://twitter.com/jamesclay</uri
<http://twitter.com/jamesclay%3C/uri> >

	    </author>

	  </entry>

	 

	I want to be able to strip out the path to the .jpg
e.g.http://s3.amazonaws.com/twitter_production/profile_images/96243182/P
hoto14_normal.jpg

	 

	But can't work out how to do that. I can access the content of
<id>,<title> and even <name> but the tag containing the profile pic link
e.g. <link type="image/png" doesn't have a closing tag. Presumably I
need some kind of function + regular expression - any suggestions?

	 

	Cheers

	Ron

	 

	
________________________________


	Rediscover Hotmail(r): Get e-mail storage that grows with you.
Check it out.
<http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscove
r_Storage1_042009> _______________________________________________
	Xerte mailing list
	Xerte at lists.nottingham.ac.uk
	http://lists.nottingham.ac.uk/mailman/listinfo/xerte

 

________________________________

Rediscover Hotmail(r): Now available on your iPhone or BlackBerry Check
it out.
<http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscove
r_Mobile1_042009> 

 

________________________________

Windows Live(tm): Keep your life in sync. Check it out.
<http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_04200
9> 

 

________________________________

Windows Live(tm): Life without walls. Check it out.
<http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_04200
9> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20090417/da72dcf3/attachment.html


More information about the Xerte mailing list