Jump to content

stringregexp replace leading spaces of every line from edit control


gcue
 Share

Recommended Posts

hello world..

i am trying to remove the leading spaces for every line in an edit control...

i was going to cycle through each line using _GuilCtrlEdit_GetLine and remove the spaces using stringstripws

but i think this can probably done faster using stringregexp

i found this.. '?do=embed' frameborder='0' data-embedContent>>but it doesnt seem to work when i replace the - with a $

its probably because the $ isnt being read as a literal character so i tried using chr(36) - still didnt work.

any ideas?

thanks in advance

Link to comment
Share on other sites

here's a sample data set.

$string = "     $4 months" & @crlf

$string &= "       $until notice is due" & @crlf

$string & = "       $due date = 4/12/2015  " & @crlf

Edited by gcue
Link to comment
Share on other sites

$string = "     $4 months" & @crlf
$string &= "       $until notice is due" & @crlf
$string &= "       $due date = 4/12/2015  " & @crlf
ConsoleWrite($string)
$string = StringRegExpReplace($string,"(\h+)(.*)","$2")
ConsoleWrite($string)

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

$string = "     $4 months" & @crlf
$string &= "       $until notice is due" & @crlf
$string &= "       $due date = 4/12/2015  " & @crlf

$Result = StringRegExpReplace($string, "(?:\n|\A)(\s)*", "")

msgbox(0, '' , $string)
msgbox(0, '' , $Result)

edit:  with OPs example rather than link

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

nope:  the number, then the expected number of 32s (spaces), followed by a 13 (CR).  ** I am however stripping off line feeds..

#include <Array.au3>


$string = "      2  " & @crlf
$string &= "           3   " & @crlf
$string &= "       4    " & @crlf

$Result = StringRegExpReplace($string, "(?:\n|\A)(\s)*", "")

msgbox(0, '' , $string)
msgbox(0, '' , $Result)

_ArrayDisplay(StringToASCIIArray($result))

StringRegEx route leaving LF:

#include <Array.au3>

$string = "        2  " & @crlf
$string &= "           3  " & @crlf
$string &= "       4  " & @crlf

$aResult = StringRegExp($string, "(\H.*\s\n)"  , 3)

_ArrayDisplay(StringToASCIIArray(_ArrayToString($aResult , "")))
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

$string = "     $4 months" & @crlf
$string &= "       $until notice is due" & @crlf
$string &= "       $due date = 4/12/2015  " & @crlf
ConsoleWrite($string)
$string = StringRegExpReplace($string,"(?m)^\h+|\h+$", "")
ConsoleWrite($string)

Edited by jguinch
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...