I'm using a macro and search-replace to convert a list of FirstName LastName to LastName, FirstName. It works fine with the shortcut class \w, but if I replace that with [a-zA-Z0-9_] it breaks, when logically those should be the same. My actual goal is to replace \w with something like [^ ], because where it's breaking is last names that include apostrophes.
This is an example that can be inserted in a new Tiddler to demonstrate the issue; the first list is the way it's currently working (you can see Vincent D'Onofrio is out of order and not in LastName, FirstName format) and the second list is broken due to the character class issue: \define compare-by-last-name() [<currentTiddler>search-replace:i:regexp[((?:.*\s)|^)(\w+$)],[$2, $1]] \end \define compare-by-last-name-with-character-class() [<currentTiddler>search-replace:i:regexp[((?:.*\s)|^)([a-zA-Z0-9_]+$)],[$2, $1]] \end <$set name="listOfNames" value="[[Charlie Cox]] [[Vincent D'Onofrio]] [[Deborah Ann Woll]] [[Elden Henson]] [[Royce Johnson]] [[Geoffrey Cantor]] [[Jay Ali]] [[Jon Bernthal]] [[Stephen Rider]] [[Wilson Bethel]] [[Ayelet Zurer]] [[Peter McRobbie]] [[Amy Rutberg]] [[Elodie Yung]] Awkwafina" > <ul> <$list filter="[enlist<listOfNames>sortsub<compare-by-last-name>]"> <li><$link><$text text={{{[<currentTiddler>search-replace:i:regexp[(.*)(\s\w+$)],[$2, $1]]}}}/></$link></li> </$list> </ul> <ul> <$list filter="[enlist<listOfNames>sortsub<compare-by-last-name-with-character-class>]"> <li><$link><$text text={{{[<currentTiddler>search-replace:i:regexp[(.*)(\s\w+$)],[$2, $1]]}}}/></$link></li> </$list> </ul> </$set> -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f0c90269-244b-4f1b-ad2f-68c2a3e33633n%40googlegroups.com.