Skip to content

Commit a2de783

Browse files
authored
Refactor regex usage to include ##REGEX_POSIX pragma (sbcgua#217)
* Refactor regex usage to include ##REGEX_POSIX pragma * Add cl_abap_regex use
1 parent bf5009d commit a2de783

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/core/zcl_ajson.clas.abap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ CLASS ZCL_AJSON IMPLEMENTATION.
447447
if lr_item is not initial and lr_item->type = zif_ajson_types=>node_type-string.
448448
find first occurrence of regex '^(\d{4})-(\d{2})-(\d{2})(T|$)' "#EC NOTEXT
449449
in lr_item->value
450-
submatches lv_y lv_m lv_d.
450+
submatches lv_y lv_m lv_d ##REGEX_POSIX.
451451
concatenate lv_y lv_m lv_d into rv_value.
452452
endif.
453453

@@ -736,7 +736,7 @@ CLASS ZCL_AJSON IMPLEMENTATION.
736736
endif.
737737

738738
if go_float_regex is not bound.
739-
create object go_float_regex exporting pattern = '^([1-9][0-9]*|0)\.[0-9]+$'.
739+
create object go_float_regex exporting pattern = '^([1-9][0-9]*|0)\.[0-9]+$' ##REGEX_POSIX.
740740
" expects fractional, because ints are detected separately
741741
endif.
742742

src/core/zcl_ajson.clas.locals_imp.abap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class lcl_utils implementation.
305305
" A lightweight check covering the top-level JSON value would look like this
306306
" ^\s*(\{.*\}|\[.*\]|"(?:\\.|[^"\\])*"|true|false|null|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\s*$
307307
" Unfortunately, this is quite slow so we use a trivial check of the beginning of the JSON data
308-
find regex '^\s*(true|false|null|-?\d|"|\{|\[)' in iv_data.
308+
find regex '^\s*(true|false|null|-?\d|"|\{|\[)' in iv_data ##REGEX_POSIX.
309309
if sy-subrc <> 0.
310310
zcx_ajson_error=>raise(
311311
iv_msg = |Json parsing error: Not JSON|
@@ -1211,7 +1211,7 @@ class lcl_json_to_abap implementation.
12111211

12121212
find first occurrence of regex '^(\d{4})-(\d{2})-(\d{2})(T|$)' "#EC NOTEXT
12131213
in iv_value
1214-
submatches lv_y lv_m lv_d.
1214+
submatches lv_y lv_m lv_d ##REGEX_POSIX.
12151215
if sy-subrc <> 0.
12161216
zcx_ajson_error=>raise( 'Unexpected date format' ).
12171217
endif.
@@ -1269,7 +1269,7 @@ class lcl_json_to_abap implementation.
12691269
in iv_value submatches
12701270
ls_timestamp-year ls_timestamp-month ls_timestamp-day ls_timestamp-t
12711271
ls_timestamp-hour ls_timestamp-minute ls_timestamp-second
1272-
ls_timestamp-local_sign ls_timestamp-local_hour ls_timestamp-local_minute.
1272+
ls_timestamp-local_sign ls_timestamp-local_hour ls_timestamp-local_minute ##REGEX_POSIX.
12731273

12741274
if sy-subrc = 0.
12751275

@@ -1280,7 +1280,7 @@ class lcl_json_to_abap implementation.
12801280
find first occurrence of regex lc_regex_ts_utc
12811281
in iv_value submatches
12821282
ls_timestamp-year ls_timestamp-month ls_timestamp-day ls_timestamp-t
1283-
ls_timestamp-hour ls_timestamp-minute ls_timestamp-second ls_timestamp-frac.
1283+
ls_timestamp-hour ls_timestamp-minute ls_timestamp-second ls_timestamp-frac ##REGEX_POSIX.
12841284

12851285
if sy-subrc <> 0.
12861286
zcx_ajson_error=>raise( 'Unexpected timestamp format' ).
@@ -1334,7 +1334,7 @@ class lcl_json_to_abap implementation.
13341334

13351335
find first occurrence of regex '^(\d{2}):(\d{2}):(\d{2})(T|$)' "#EC NOTEXT
13361336
in iv_value
1337-
submatches lv_h lv_m lv_s.
1337+
submatches lv_h lv_m lv_s ##REGEX_POSIX.
13381338
if sy-subrc <> 0.
13391339
zcx_ajson_error=>raise( 'Unexpected time format' ).
13401340
endif.

src/libs/zcl_ajson_mapping.clas.locals_imp.abap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class lcl_mapping_camel implementation. "DEPRECATED
191191

192192
rv_result = iv_name.
193193

194-
replace all occurrences of regex `([a-z])([A-Z])` in rv_result with `$1_$2`. "#EC NOTEXT
194+
replace all occurrences of regex `([a-z])([A-Z])` in rv_result with `$1_$2` ##REGEX_POSIX. "#EC NOTEXT
195195

196196
endmethod.
197197

@@ -276,7 +276,7 @@ class lcl_to_snake implementation.
276276

277277
method zif_ajson_mapping~rename_node.
278278

279-
replace all occurrences of regex `([a-z])([A-Z])` in cv_name with `$1_$2`. "#EC NOTEXT
279+
replace all occurrences of regex `([a-z])([A-Z])` in cv_name with `$1_$2` ##REGEX_POSIX. "#EC NOTEXT
280280
cv_name = to_lower( cv_name ).
281281

282282
endmethod.

0 commit comments

Comments
 (0)