anibalgallego Posted January 18, 2020 Share Posted January 18, 2020 I come from here: https://www.autoitscript.com/forum/topic/36064-string-delete-after-character/ Im trying to copy some multiline text like this from clipboard: text text tex text 123x 2x34 345 text text tex text 123 23x4 3x45 text text tex text 123 2x34 345 So I need to remove any character after "spaces" in every line and putit into clipboard with this format: text text tex text text text tex text text text tex text Im using StringLeft and I it's alright for one line. Is possible to make it multiline? $String = ClipGet() $OutPut = StringLeft($String, StringInStr($String, ' ') + 0) ClipPut ($OutPut) Thank you! Link to comment Share on other sites More sharing options...
gamerman2360 Posted January 18, 2020 Share Posted January 18, 2020 Opt("ExpandVarStrings", 1) $in = "text text tex text 123x 2x34 345@CRLF@" & _ "text text tex text 123 23x4 3x45@CRLF@" & _ "text text tex text 123 2x34 345" $in = StringSplit(StringStripCR($in), @LF) $out = "" For $i = 1 To $in[0] $out &= StringLeft($in[$i], StringInStr($in[$i], ' ') + 0) & @LF Next ConsoleWrite($out) I would use StringSplit. Link to comment Share on other sites More sharing options...
anibalgallego Posted January 18, 2020 Author Share Posted January 18, 2020 Works great!! Ive changed $in = "text text tex text 123x 2x34 345@CRLF@" & _ "text text tex text 123 23x4 3x45@CRLF@" & _ "text text tex text 123 2x34 345" for $in = ClipGet() And its perfect THNKS!! Link to comment Share on other sites More sharing options...
mikell Posted January 18, 2020 Share Posted January 18, 2020 and the (simple) regex which fits nice... $txt = "text text tex text 123x 2x34 345" & @crlf & _ "text text tex text 123 23x4 3x45" & @crlf & _ "text text tex text 123 2x34 345" $res = StringRegExpReplace($txt, '(?m)^(.*?)\h{2,}.*', "$1") Msgbox(0,"", $res) gamerman2360 and anibalgallego 2 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