myname1 Posted October 28, 2008 Share Posted October 28, 2008 (edited) How to remove the bolded texts automatically?Example 1 - Between "11" and "22":ab11cde21fg22hiabc11de21f22ghiabcd11e2122fghiDone with Regular Expression, see below.Example 2 - Between "^*" and "~|" (extra chars):ab^*cde21fg~|hiabc^*de21f~|ghiabcd^*e21~|fghiDone with Regular Expression, see below.Example 3 - From first "1" to begin:ab11cde21fg22hiabc11de21f22ghiabcd11e2122fghiExample 4 - From last "2" to end:ab11cde21fg22hiabc11de21f22ghiabcd11e2122fghiAll help is welcome. Edited November 1, 2008 by myname1 Link to comment Share on other sites More sharing options...
Valuater Posted October 28, 2008 Share Posted October 28, 2008 StringBetween() StringLeft() StringRight() ... ???? automatic is a very open question 8) Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 28, 2008 Share Posted October 28, 2008 In this case, I see regular expressions as the fastest way to do this. For instance, the first could easily be done by using a regular expression replacement of "11.*?22" with "".What exactly are you looking for? Link to comment Share on other sites More sharing options...
myname1 Posted October 28, 2008 Author Share Posted October 28, 2008 (edited) StringBetween()StringLeft()StringRight()... ????automatic is a very open question8)I don't know what do you mean. Can you explain more? In this case, I see regular expressions as the fastest way to do this. For instance, the first could easily be done by using a regular expression replacement of "11.*?22" with "".What exactly are you looking for?Thanks for telling me that. Now I figured out how to use regular expression for the first two examples.Example 1 done by regular expression:11.*22Example 2 done by regular expression:\^\*.*\~\|Other two are still undone. I tried this for example 3: ^.*1, but it worked like this:ab11cde21fg22hiabc11de21f22ghiabcd11e2122fghiAnyone know how to do the trick for last two examples? Edited October 28, 2008 by myname1 Link to comment Share on other sites More sharing options...
picaxe Posted October 28, 2008 Share Posted October 28, 2008 $t = "ab11cde21fg22hi" & @CRLF & "abc11de21f22ghi" & @CRLF & "abcd11e2122fghi" ConsoleWrite(StringRegExpReplace($t, "(^|\r\n|\n)(\D*1)(.*)", "$1$3") & @LF) ConsoleWrite(StringRegExpReplace($t, "(.*)(2\D*)(\n|\r\n|$)", "$1$3") & @LF) Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 28, 2008 Share Posted October 28, 2008 It's because you are using the greedy star. Use a lazy star instead. "^.*?1" Link to comment Share on other sites More sharing options...
myname1 Posted November 1, 2008 Author Share Posted November 1, 2008 $t = "ab11cde21fg22hi" & @CRLF & "abc11de21f22ghi" & @CRLF & "abcd11e2122fghi" ConsoleWrite(StringRegExpReplace($t, "(^|\r\n|\n)(\D*1)(.*)", "$1$3") & @LF) ConsoleWrite(StringRegExpReplace($t, "(.*)(2\D*)(\n|\r\n|$)", "$1$3") & @LF) Is that "$t ="-line necessary? I mean that if I have more than 3 different lines, that would be a quite huge line. It's because you are using the greedy star. Use a lazy star instead. "^.*?1" I can't get that lazy star (*?) working. It gives no results. So lazy star isn't supported in all editors like SciTE? Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 1, 2008 Share Posted November 1, 2008 Scite is an editor, not an interpreter. AutoIt supports the lazy star. It's in the documentation if you had read it. 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