0

I have the following jdbc url:

jdbc:mysql:${env.ABC_MY_URL}/my_schema${env.DEF_MY_SUFFIX:}?characterEncoding=UTF-8

I need two regexp that match (something)MY_URL and (something)MY_SUFFIX, because i need to replace them with others value.

What i wrote now is this:

/(\..*?_URL)/g

This correctly match (something)MY_URL (i tried to include the fullstop at first) but if i try to replace it with this:

/(\..*?_SUFFIX)/g

This match the entire string from the first fullstop untill MY_SUFFIX

I just need to extract (something)MY_URL and (something)MY_SUFFIX, because need to replace them with other values.

The value ABC and DEF could change, for this reason i would like to match (something)_MY_URL and (something)_MY_SUFFIX

I'm totally unexpert of regexpr :(

Mistre83
  • 2,677
  • 6
  • 40
  • 77
  • 1
    You need `(\.[^.]*?_SUFFIX)`, see [this answer](https://stackoverflow.com/a/21478871/3832970). – Wiktor Stribiżew Apr 30 '20 at 12:15
  • 1
    I can say understood.. but is not true.. :D Anyway, i need two distinct expression to match this cases. The first i wrote (dont know if is correct.. but works :)) And the second you told me – Mistre83 Apr 30 '20 at 12:20
  • The point is the `.` matches any char but line break chars, and matching starts with the leftmost occurrence (as the text is parsed from left to right). – Wiktor Stribiżew Apr 30 '20 at 12:25
  • I have another little problem :( I'll need to do this matches just if the string begin with jdbc :( So a simple ${env.ABC_MY_URL} wont match. And jdbc...${env.ABC_MY_URL} shoud match.. (because begin with jdbc) – Mistre83 Apr 30 '20 at 16:28
  • 1
    See https://regex101.com/r/Ln0ULx/1 – Wiktor Stribiżew Apr 30 '20 at 16:33

0 Answers0