It is currently March 28th, 2024, 8:36 pm

Help with reg ex please

Get help with creating, editing & fixing problems with skins
Mascott
Posts: 18
Joined: September 5th, 2016, 4:36 pm

Help with reg ex please

Post by Mascott »

HI All
Have bin trin g to get my head round RegExpSubstitute and the Substitute values so i can use the serial number part of my hwinfo sensername for my ssd so i can add it to a meter i am making but for the life of me i cant get the part i need to show(just the serial numbers).
Here is what i am trying to cut down.. S.M.A.R.T.: Samsung SSD 850 EVO 250GB (S21NNSAG732039X) so it just shows the end part with just the serial numbers S21NNSAG732039X, can anybody give me a clue how to just delete letters and spaces so i can just end up with what i need
Thanks in advance for any help and have made a rmskin package with all what i have got so far
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with reg ex please

Post by jsmorley »

Use this Substitute on the measure you have returning that string...

Code: Select all

[MeasureSSD]
Measure=String
String=S.M.A.R.T.: Samsung SSD 850 EVO 250GB (S21NNSAG732039X)
RegExpSubstitute=1
Substitute=".*\((.*)\).*":"\1"
What it is saying is:

".*\((.*)\).*"

.* skip everything until
\( a literal open parentheses is reached
( start capturing
.* any number of any characters ) until
\) a literal close parentheses is reached.
.* skip til the end

"\1"

replace everything with just the (captured) characters


1.jpg
You do not have the required permissions to view the files attached to this post.
β€’ deviantART Profile β€’ Current Desktop β€’ Rainmeter Manual β€’
Mascott
Posts: 18
Joined: September 5th, 2016, 4:36 pm

Re: Help with reg ex please

Post by Mascott »

Thank you so much js Morley, have bin getting so frustrated trying to work this out and you have explained it so easy πŸ˜ƒπŸ˜ƒπŸ˜ƒ πŸ‘πŸ‘πŸ‘