File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
main/java/com/dashjoin/jsonata
test/java/com/dashjoin/jsonata Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,11 @@ Pattern scanRegex() {
139139 throw new JException ("S0301" , position );
140140 }
141141 position ++;
142- currentChar = path .charAt (position );
142+ if (position < length ) {
143+ currentChar = path .charAt (position );
144+ } else {
145+ currentChar = 0 ;
146+ }
143147 // flags
144148 start = position ;
145149 while (currentChar == 'i' || currentChar == 'm' ) {
Original file line number Diff line number Diff line change 1+ package com .dashjoin .jsonata ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+
6+ public class RegexTest {
7+ @ Test
8+ public void testRegex () {
9+ var expression = Jsonata .jsonata ("/^test.*$/" );
10+ Object evaluate = expression .evaluate (null );
11+ String expected = "^test.*$" ;
12+ Assertions .assertEquals (expected , evaluate .toString ());
13+ }
14+
15+ @ Test
16+ public void testEvalRegex () {
17+ var expression = Jsonata .jsonata ("$eval('/^test.*$/')" );
18+ Object evaluate = expression .evaluate (null );
19+ String expected = "^test.*$" ;
20+ Assertions .assertEquals (expected , evaluate .toString ());
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments