I have this Descriptions
Description |
---|
T2 SMD MOS N/P SI1555 SOT363 700/600mA 20/8V -55/150C Dual 390/850mOHM |
T2 SMD MOS N/P FDS8858CZ SO-8 8.6/7.3A 30V 0.017OHM |
T2 SMD MOS N/P EM6M2T2R SOT563 200/200mA 20V 1OHM ESD PROT |
FLTR SMD 0603 FER BEAD 220OHM @100MHZ /-25% 0,4OHM 1.4A |
What I want to return is:
Current |
---|
700/600mA |
8.6/7.3A |
200/200mA |
1.4A |
For that I tried this regex
(\s|^)(-)?(\d \.?\d*(A|mA)(DC|AC)?)(?=\s|$)
I could not get it to work with values containing a /
as 700/600mA
, 8.6/7.3A
, 200/200mA
How could I correct my regex?
CodePudding user response:
You can use
(?<!\S)-?\d (?:\.\d )?(?:/-?\d (?:\.\d )?)?m?A(?:[DA]C)?(?!\S)
Explanation
(?<!\S)
Assert a whitespace boundary to the left-?\d (?:\.\d )?
Match 1 digits with an optional decimal part(?:/-?\d (?:\.\d )?)?
Optionally match/
and 1 digits with an optional decimal partm?A
Match an optionalm
followed byA
(?:[DA]C)?
Match optionalDA
orAC
(?!\S)
Assert a whitespace boundary to the right
If you meant to match m
mA
DC
AC
the optional group should be part of the alternation:
(?<!\S)-?\d (?:\.\d )?(?:/-?\d (?:\.\d )?)?(?:m?A|[DA]C)(?!\S)
CodePudding user response:
You could use
([\d./]{2,}m*A )
if you don't need to catch all matches in the same pattern
CodePudding user response:
(\d (\.\d )?\/)?\d (\.\d )?[m]?A