File tree Expand file tree Collapse file tree
core/src/main/kotlin/org/evomaster/core/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,6 +141,18 @@ data class RegexFlags(
141141 }
142142 }
143143
144+ fun toJavaFlagBitmask (): Int {
145+ var flags = 0
146+ if (caseInsensitive) flags = flags or Pattern .CASE_INSENSITIVE
147+ if (unicodeCase) flags = flags or Pattern .UNICODE_CASE
148+ if (dotAll) flags = flags or Pattern .DOTALL
149+ if (multiline) flags = flags or Pattern .MULTILINE
150+ if (unixLines) flags = flags or Pattern .UNIX_LINES
151+ if (unicodeCharacterClass) flags = flags or Pattern .UNICODE_CHARACTER_CLASS
152+ if (comments) flags = flags or Pattern .COMMENTS
153+ return flags
154+ }
155+
144156 /* *
145157 * Merges this [RegexFlags] with a [ParsedFlagExpression], returning a new [RegexFlags] with the
146158 * enabled flags turned on and the disabled flags turned off.
@@ -161,6 +173,15 @@ data class RegexFlags(
161173 if (comments) throw IllegalStateException (" Regex flag 'x' (COMMENTS) is not yet supported" )
162174 }
163175
176+ /* *
177+ * Checks if the provided character is a line terminator according to the flag behavior.
178+ */
179+ fun isLineTerminator (c : Char ) = if (unixLines) {
180+ c == ' \n '
181+ } else {
182+ c == ' \n ' || c == ' \r ' || c == ' \u0085 ' || c == ' \u2028 ' || c == ' \u2029 '
183+ }
184+
164185 /* *
165186 * Checks if the provided character has a case variant according to the flag behavior, checking both caseInsensitive
166187 * and unicodeCase flag values.
You can’t perform that action at this time.
0 commit comments