Subject: [tw] Re: RegEx for matching a string of tags... > Hi all, if anyone needs a RegEx to take a string full of tags and > break it into an array of valid tags, using: > var tagList = tagString.match(/(\[{2}(\w+(\.?|\S?)(\s?)(\w*))+\] > {2})|(\[(\w+((\S)\w+)*(\S?)))|(\w+((\S)\w+)*(\S?))/gi); > > works on a complex example string like: > > Tag1 [[another tag]] moretags tag.one [[her's]] paul's [[david's > meeting]][[feb. 16th asdf]] something [[somethingelse]] somethingelse? > [[something's got's to. No? give!]] period. [[three word tag]] > [wrongtag] wonder's [[[three brackets]]] [one bracket] these's > those.twice.again periods.twice. Interesting work on the regexp. I like the idea of parsing the tags string with regexp because it is very efficient. Howevern the TWCore defines a string method, .readBracketedList(), which is used to parse tag string input and populate the internal tiddler data structure in the 'store'. Thus, you would write: var tagList = tagString.readBracketedList(); to get the actual tags that the core will use. You should do a little comparison to make sure your regexp produces the same results. enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@xxxxxxxxxxxxxxxxx To unsubscribe from this group, send email to tiddlywiki+unsubscribe@xxxxxxxxxxxxxxxxx For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en. |