JPRegex

JPRegex

JPRegex is a cross-platform LUA regex engine
Version : 1.0
Price : $20
State : Out

API

--JPRegex API JPRegex.activate ( sUserToken, sActivationKey ) --Match bMatch, tMatch, sError = JPRegex.matchFirst ( sPattern, sString, sOptFlags ) bMatch, tMatches, sError = JPRegex.matchAll ( sPattern, sString, sOptFlags ) bMatch, tMatches, sError = JPRegex.matchAllWithOverlaps ( sPattern, sString, sOptFlags ) --Match result sText = JPRegex.getMatchText ( tMatch ) nPosition = JPRegex.getMatchPosition ( tMatch ) --Get capturing group result sText = JPRegex.getMatchGroupText ( tMatch, nGroup ) nPosition = JPRegex.getMatchGroupPosition ( tMatch, nGroup ) --Replace sRes, nReplaceCount, sError = JPRegex.replaceFirst ( sPattern, sString, sReplace, sOptFlags ) sRes, nReplaceCount, sError = JPRegex.replaceAll ( sPattern, sString, sReplace, sOptFlags ) --Explode tExplode, sError = JPRegex.explode ( sPattern, sString, sOptFlags )

Description

JPRegex is a LUA regex engine that will allow you to work with regular expressions in ShiVa. As it is all done in LUA, it will work on any platform a ShiVa game can be exported to, without worries about compatibility. You will find below the list of what JPRegex currently supports :

CHARACTER CLASSES A : character [ABC] : character set [^ABC] : negated set [A-Z] : range . : any character (except new line if flag 's' is not set) ESCAPED CHARACTERS + : match a reserved character (+*?^$.[]{}()|/) : tabulation character : line feed character w : word -> (alphanumeric & underscore, no accented characters). Equivalent to [A-Za-z0-9_] W : not word -> Matches any character that is not a word character (alphanumeric & underscore). Equivalent to [^A-Za-z0-9_] d : digit -> equivalent to [0-9] D : not digit -> equivalent to [^0-9] s : a white space or tab or line break S : not a white space or tab or line break ANCHORS ^ : beginning $ : end GROUPS AND REFERENCES (ABC) : capturing group QUANTIFIERS AND ALTERNATION + : 1 or more of the preceding token, as much as possible * : 0 or more of the preceding token, as much as possible {1} or {1,3} or {3,} or {,3} : quantifier for the preceding token ? : optional -> quantity of 0 or 1 of the preceding token ? : lazy -> makes the preceding quantifier lazy, causing it to match as few characters as possible. (A|Z) : alternation -> | acts like a OR boolean. The patterns will be tested in order POSIX notations : [[:punct:]] : not whitespace, letters or numbers [[:lower:]] : Equivalent to [a-z] [[:upper:]] : Equivalent to [A-Z] [[:alnum:]] : Equivalent to [A-Za-z0-9] [[:alpha:]] : Equivalent to [A-Za-z] [[:blank:]] : Equivalent to [ ] -> Matches spaces and tabs (but not newlines) [[:digit:]] : Equivalent to [0-9] [[:word:]] : Equivalent to w or [a-zA-Z0-9_] SUBSTITUTION : $1 : capture group -> Inserts the results of the specified capture group. $$ : escaped $ -> Inserts a $ sign $& : match -> Inserts the matched text FLAGS : U : ungreedy : will be as_few_as_possible by default and '?' following a quantifier will make it greedy s : single line -> the dot (.) ca also match new lines