The Identification Number and Password fields need to be filled in. Moreover, you cannot send messages devoid of contents Adding further data is not allowed because this topic has been closed Print You provided no password: you have to write it in the textfield beside the command delete for the topic you want to delete Are you sure you want to delete this comment? You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed
 
member picmember pic
 
Snippets of ALBERTO
 
info Below you can find the text of the snippet you want to read, and the list of the other snippets by this author if available.
What are snippets?
Share Share on MySpace Delicious Delicious

Javascript Split A String Using A Regular Expression Pattern

Snippet: Identification Number »   Snippet: Inclusion syntax »
Saturday June 23, 2007 - 20:40:22
Visitors: 10,804 Daily average: 9 Tagged by its author as: Programming Javascript Characters (in origin): 2,221 (pages: ~ 1)
Permalink Cast your vote for this topic 0 Printable version
OBJECTIVE: given a string in Javascript find a set of matches via a regular expression, then split the input string by such matches.  
 
Unlike Php, Javascript has no built in function such as preg_split to achieve this goal.  
function isplit(string, regexp, flags){
var splitter="#@#";
while(string.indexOf(splitter)!=-1){ splitter+="#"; };
flags=(flags && typeof(flags)=="string")?flags:
(!isNaN(parseFloat(flags)))?"":"g";
string=string.replace(
	((typeof(regexp)=="string")?new RegExp(regexp, flags):regexp),
	splitter
);
return string.split(splitter);
/*keep this comment to use freely
http://www.fullposter.com/?1 */}
INPUTS: first the string to split.  
 
Then either a Javascript regular expression, or a string.  
 
Then an optional third argument carrying the flags of the regular expression such as g for retruning all ther matches or i for case insensitive match searches).  
If this argument is passed as a Number (instance: 0), it would add no modifiers.  
If not passed at all, it defaults to a global match detection, which is arguably exactly what is meant for such a task.  
 
RETURNS: an array, each item a string fragment from the split input string.  
 
CAVEATS: the function recursively builds a string making sure it is not present within the input string, and once found it, it replaces with it the found matches; then it splits by such string.  
This procedure seems more straightforward than painstakingly looping the matches grabbing per each found match the input string substrings to concatenate and making sure, at each iteration, to locate the right input string offset (matches, since they are derived from a regular expression, follow a pattern and normally do not represent an exact set of chars; therefore, each match may differ from the other); anyway that could have been an alternative way to do it - TIMTOWTDI, but I am not even sure if it would have been more efficient.  
 
A similar task is achieved at Javascript Regular Expression Match: Return The Indexes Of The Matches.
Printable version To exclude hyperlinks from the print, check the checkbox »
Rss
Cast your vote for this topic To perform this operation it is not necessary to be Full Poster members.
«Negative Positive»
Click here to save your vote (Current average: 0.00, Voters: 0)
Other topics
This subscriber has a blog too: Read the blog. Shoutbox: 82 reviews: 170
Visitors: 10,804
Daily average: 9
Overall visits to all the topics: 1,677,024
Daily average (Calculated from the website subscription day): 1,153.39
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Javascript
Current order: by category: Dictionaries
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(1), Books(226), Critical Reviews and Essays(5), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(1), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Philosophy Reviews(2), Programming(3), Programming Ajax(1), Programming Javascript(65), Programming Php(47), Quotes(1), Religion Esoterica and Spirituality(9), Scientifical Reviews(4), Self Improvement(1), Tarots(1)
Showing topics: 1, 20
Available total: 396
View only a list of the snippets by this author: click here.
Other topics available for this author: click on any title below to view the complete item:
A Personal Dictionary Of Differences: Constraints Identification Number: 281 Friday June 27, 2008 - 12:27:32 Visitors: 3,505
««« Previous Next »»»
External services
This page of this subscriber uses external services: Hide

Footers

search profiles Join Update poster
reviews Blog Snippets Polls
Favourite web sites Shoutbox Chat Statistics
frequently asked questions Manuals Terms Of Service Contact Full Poster
Applications Discussion groups Free Area Events
Copyright © Full Poster - 2006, 2010 - All rights reserved