Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 17945

Regular expression to get a specific group

$
0
0

I have this expression: (\D)((-?|+?)\d+(.\d+)?)?. This work for the most of the patterns i get. But, exists this pattern in the string that a i don't be abble to get at all. I'm using Java with spring boot

This is the string that a apply the regex:

$1.0?8S0.0H692.8Q651.7u3.3o294.8n0t32.6s0R0.0P0.0Y114.9|136.3%1N-22.08930501E-48.05973392D692.374U0.0V0.00O0.0I6G0.20F12h0.000v0.000x1y1a24.0412e5.0690b0.00l0.0000r0.0000f0p4¨0.0@0.0c0.0d0.0º0|0|0|0=51.9988B1.0#0

It's is simply, get the first character that's not a letter, after get the plus or minus character, after get the number. if exists a float point, get the point with the remnant numbers. This is the common pattern. The result is something like:

  • $ - 1.0
  • ? - 8
  • S - 0.0
  • = - 51.9988
  • t - 32.6

After a put this in a HashMap.

But there is a part that i have more than one number to get, separated by pipe :

  • Y114.9|136.3

  • º0|0|0|0

Because of the firts rule, this is interpreted as another value.

I want to change the regex to deal with this specific rule. To get something like this:

  • Y - 114.9 | 136.3
  • º - 0 | 0 | 0 | 0

After this i will develop a logic to put this in an array

Thank's to anyone for the help


Viewing all articles
Browse latest Browse all 17945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>