Jump to content

Recommended Posts

Posted

hello, i have a variable ($s1Text) that equals this:

  Quote

" Cancel

Searchresult No Documents Found

"

I'm not sure how to make this condition true:

if $s1Text = "" then
   MsgBox(0, "Body Text", "true")
EndIf

i tried to count the number of line breaks and substituting them with & Chr(13) - but i couldnt get that to work...

Posted

Just a variation on Valuaters code that will only get the blank line count.

$string = fileread("Tester.txt")
StringRegExpReplace($string, "(?m:^)\v", "")
MsgBox(4096, "Results", "There are " & @Extended & " empty lines")

George

  Reveal hidden contents
Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

  Valuater said:

Welcome

@GEO ... :)

8)

Hope you realize that technically we are both incorrect. To get the count only the replace string should be the same as the search string. In your case

$string = StringReplace($string, @CRLF, @CRLF)

and in mine

StringRegExpReplace($string, "(?m:^)(\v)", "$1")

Also, using the regexp, it will get empty lines no matter what vertical character was used for the line terminator, char() 10 through 13

:o

George

  Reveal hidden contents
Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

  PsaltyDS said:

I think y'all been into the Egg Nogg and are over-thinking it a bit:

If StringStripWS($s1Text, 8) = "" Then
   MsgBox(0, "Body Text", "true")
EndIf

:)

Everybody is missing the point that the OP asked for a COUNT of the blank lines.

Edit: Actually I'm wrong In that. He just wants to replace all of the line breaks with Chr(13). Therefore my code should have been

$string = fileread("Tester.txt")
$string = StringRegExpReplace($string, "\r\n|\v", Chr(13))

That will replace any vertical WS character with Chr(13) and it wont matter if the line actually ended with @CRLF, @CR, @LF or a vertical tab or Form Feed

Edited by GEOSoft

George

  Reveal hidden contents
Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

  GEOSoft said:

Everybody is missing the point that the OP asked for a COUNT of the blank lines.

Edit: Actually I'm wrong In that. He just wants to replace all of the line breaks with Chr(13). Therefore my code should have been

$string = fileread("Tester.txt")
$string = StringRegExpReplace($string, "\r\n|\v", Chr(13))

That will replace any vertical WS character with Chr(13) and it wont matter if the line actually ended with @CRLF, @CR, @LF or a vertical tab or Form Feed

Well, it would be best if gcue answered for himself, but the code he posted in post #1 was a test for a null string, that he seemed to want to be true even if there were multiple blank lines. The rest was about achieving that, which StringStripWS() does nicely.

You've just been around Ron long enough that every problem looks like a RegExp!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

  PsaltyDS said:

You've just been around Ron long enough that every problem looks like a RegExp!

:)

Are you syaing I've been brainwashed? Probably true.

George

  Reveal hidden contents
Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

  GEOSoft said:

Are you syaing I've been brainwashed? Probably true.

Func _SmOke_N_Reeducation()
      $GEOSoft = StringRegExpReplace($GEOSoft, "[[:reality:]]", $NewSpeak)
EndFunc

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
  • Moderators
Posted

  PsaltyDS said:

Func _SmOke_N_Reeducation()
      $GEOSoft = StringRegExpReplace($GEOSoft, "[[:reality:]]", $NewSpeak)
EndFunc

:)

You've obviously not seen this rare occasion : http://www.autoitscript.com/forum/index.ph...st&p=622128

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
  • Recently Browsing   0 members

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