Skyrim Special Edition
0 of 0

File information

Last updated

Original upload

Created by

Meridiano

Uploaded by

MeridianoRus

Virus scan

Safe to use

Documentation

Readme

View as plain text

You can see there are no "MatchExpression" or "ReplaceExpression" string arguments in mod's functions. This was made because case matters for RegEx but not for Papyrus so all patterns and RegEx modifiers are stored in TXT files in "Data/SKSE/Plugins/SkyRegEx" folder to prevent CaSe-MeSs in your work (I hope partially).

So you pass sFilename, iPatternLine, iReplaceLine, iModLineA and iModLineB arguments.
- sFilename is filename without extension.
- iPatternLine is Nth line in your file with match expression.
- iReplaceLine is Nth line in your file with replace expression.
- iModLineA is Nth line in your file with RegEx compile modifiers.
- iModLineB is Nth line in your file with RegEx match/replace modifiers.

Why modifiers are separated - there are two groups of them. 1st is applied on expression compile, 2nd is applied on match/replace operation.
- Compile modifiers are listed here > https://github.com/jpcre2/jpcre2#default-compile-modifiers
- Match/Replace modifiers are listed here > https://github.com/jpcre2/jpcre2#default-replace-or-match-modifiers

:: More About Match[...] Functions ::
Here I will go down from more complex to less.
- MatchData is all groups in all matches.
- MatchInfo is all groups counts in all matches so if you sum all MatchInfo elements you will get MatchData length.
- MatchCount is all matches count so it's equal to MatchInfo length.
- IsMatching is boolean "are there any matches?" so it's equal to (MatchCount > 0).

:: More About MatchResult Function ::
First you need to get MatchInfo and MatchData arrays. Then you need to pass them to MatchResult with iMatch and iGroup specified.
- iMatch - is Nth match. It begins from 1, not from 0, there's no #0 match.
- iGroup - is Nth group within this Nth match. It begins from 0. #0 group is the whole match, #1 group is #1 group, #2 is #2, etc.

:: Example File ::
There's an example file in "Data/SKSE/Plugins/SkyRegEx" folder. How do you use it? Here you are:

Set ParsingString to "Cześć mam na imię Oleg". This is Polish to show you how special symbols are supported. You can't use
String ParsingString = "Cześć mam na imię Oleg"
probably (compiler will mess it) so pull it from somewhere like NPC name maybe.

Bool bMatching = SkyRegEx.IsMatching(ParsingString, "SkyRegEx", 9, 12, 15) ; returns true
Int iMatchCount = SkyRegEx.MatchCount(ParsingString, "SkyRegEx", 9, 12, 15) ; returns 5
Int[] aMatchInfo = SkyRegEx.MatchInfo(ParsingString, "SkyRegEx", 9, 12, 15) ; returns [3, 3, 3, 3, 3]
String[] aMatchData = SkyRegEx.MatchData(ParsingString, "SkyRegEx", 9, 12, 15) ; returns ["Cześć ", "Cześć", " ", "mam ", "mam", " ", "na ", "NA", " ", "imię ", "imię", " ", "Oleg", "Oleg", ""]

Here you can see aMatchInfo shows you 5 matches with 3 groups in each so there are 15 groups in total in aMatchData. Do you want to get specific group?

String Match4_Group1 = SkyRegEx.MatchResult(aMatchInfo, aMatchData, 4, 1) ; returns "imię" string, this is the 1st group in the 4th match indeed.