NoizeBit Posted September 8, 2015 Share Posted September 8, 2015 (edited) Greetings to all the RegEx gurus out there I'm trying my best to learn it and already started doing so, although it'd be nice to have some help with an expression.I have these created on a regex generator site in pcre (php): /^.*Instrument.*$ /^((?![2][8]-[0][8]-[1][5]).)*$ /gmThese are working great on their own. Could you guys help me how to combine them into one expression if possible and convert it to StringRegExpReplace? Edited September 8, 2015 by NoizeBit Link to comment Share on other sites More sharing options...
jguinch Posted September 8, 2015 Share Posted September 8, 2015 Please give use an example of a input string and the expected result.You want to replace what by what ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
NoizeBit Posted September 8, 2015 Author Share Posted September 8, 2015 Input: Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return, High / Low,High,GBP/USD,35949250,01-09-15 17:52:12,24.00,1.53088,1.53147,01-09-15 18:30:00,43.68, High / Low,Low,EUR/USD,35824912,28-08-15 17:50:57,24.00,1.12031,1.11823,28-08-15 18:30:00,43.92, High / Low,High,EUR/JPY,35693949,26-08-15 11:51:27,24.00,136.331,136.30800,26-08-15 12:30:00,0.00,Output:Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return, High / Low,Low,EUR/USD,35824912,28-08-15 17:50:57,24.00,1.12031,1.11823,28-08-15 18:30:00,43.92,I'd like to delete all the lines not containing the string "28-08-15". Link to comment Share on other sites More sharing options...
jguinch Posted September 8, 2015 Share Posted September 8, 2015 ?$string = "Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return," & @CRLF & _ "High / Low,High,GBP/USD,35949250,01-09-15 17:52:12,24.00,1.53088,1.53147,01-09-15 18:30:00,43.68," & @CRLF & _ "High / Low,Low,EUR/USD,35824912,28-08-15 17:50:57,24.00,1.12031,1.11823,28-08-15 18:30:00,43.92," & @CRLF & _ "High / Low,High,EUR/JPY,35693949,26-08-15 11:51:27,24.00,136.331,136.30800,26-08-15 12:30:00,0.00," $output = StringRegExpReplace($string, "\R.+(?!28-08-15)(\d{2}-){2}\d{2}\V+", "") ConsoleWrite($output) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
kylomas Posted September 8, 2015 Share Posted September 8, 2015 NoiseBit,If this is related to your screen scraping ditty from yesterday, perhaps you would like to substitute todays date using as variable...$string = "Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return," & @CRLF & _ "High / Low,High,GBP/USD,35949250,08-09-15 17:52:12,24.00,1.53088,1.53147,08-09-15 18:30:00,43.68," & @CRLF & _ "High / Low,High,GBP/USD,35949250,01-09-15 17:52:12,24.00,1.53088,1.53147,01-09-15 18:30:00,43.68," & @CRLF & _ "High / Low,Low,EUR/USD,35824912,28-08-15 17:50:57,24.00,1.12031,1.11823,28-08-15 18:30:00,43.92," & @CRLF & _ "High / Low,Low,EUR/USD,35824912,08-09-15 17:50:57,24.00,1.12031,1.11823,08-09-15 18:30:00,43.92," & @CRLF & _ "High / Low,High,EUR/JPY,35693949,26-08-15 11:51:27,24.00,136.331,136.30800,26-08-15 12:30:00,0.00," local $sToday = @MDAY & '-' & @MON & '-' & stringright(@YEAR,2) $output = StringRegExpReplace($string, "\R.+(?!" & $sToday & ")(\d{2}-){2}\d{2}\V+", "") ConsoleWrite($output & @LF)@jguinch - I think you just answered a problem I'm having with a regex...thanks Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
NoizeBit Posted September 8, 2015 Author Share Posted September 8, 2015 NoiseBit,If this is related to your screen scraping ditty from yesterday, perhaps you would like to substitute todays date using as variable...$string = "Instrument,Type,Asset,Order #,Order Time,Invested,Target Price,Expiry Price,Expiry Time,Return," & @CRLF & _ "High / Low,High,GBP/USD,35949250,08-09-15 17:52:12,24.00,1.53088,1.53147,08-09-15 18:30:00,43.68," & @CRLF & _ "High / Low,High,GBP/USD,35949250,01-09-15 17:52:12,24.00,1.53088,1.53147,01-09-15 18:30:00,43.68," & @CRLF & _ "High / Low,Low,EUR/USD,35824912,28-08-15 17:50:57,24.00,1.12031,1.11823,28-08-15 18:30:00,43.92," & @CRLF & _ "High / Low,Low,EUR/USD,35824912,08-09-15 17:50:57,24.00,1.12031,1.11823,08-09-15 18:30:00,43.92," & @CRLF & _ "High / Low,High,EUR/JPY,35693949,26-08-15 11:51:27,24.00,136.331,136.30800,26-08-15 12:30:00,0.00," local $sToday = @MDAY & '-' & @MON & '-' & stringright(@YEAR,2) $output = StringRegExpReplace($string, "\R.+(?!" & $sToday & ")(\d{2}-){2}\d{2}\V+", "") ConsoleWrite($output & @LF)@jguinch - I think you just answered a problem I'm having with a regex...thanks @kylomas - you're right, that was the plan, thanks @jguinch - thanks a lot for helping me out Link to comment Share on other sites More sharing options...
jguinch Posted September 8, 2015 Share Posted September 8, 2015 You're welcome, both.@NoizeBit : next time, try to give us all the informations in the first message, you will have more chances to get answers if the explanation is clear enough. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
NoizeBit Posted September 13, 2015 Author Share Posted September 13, 2015 You're welcome, both.@NoizeBit : next time, try to give us all the informations in the first message, you will have more chances to get answers if the explanation is clear enough.Alright, will do. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now