Jump to content

StringRegExpReplace documentation error


Raik
 Share

Recommended Posts

This might help you in the mean time:

http://www.regular-expressions.info/tutorialcnt.html

no, this might NOT help, because the problem is not missing knowledge about regular expressions but the incorrect documented returnvalue in the autoit-documentation.

StringRegExpReplace

...

Return Value

@Error Meaning

0 Executed properly. Check @Extended for the number of replacements performed.

2 Pattern invalid. @Extended = offset of error in pattern.

thats wrong!

StringRegExpReplace returns NOT the errorcode but the replaced string.

Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Link to comment
Share on other sites

no, this might NOT help, because the problem is not missing knowledge about regular expressions but the incorrect documented returnvalue in the autoit-documentation.

thats wrong!

StringRegExpReplace returns NOT the errorcode but the replaced string.

Try this:

$text = StringRegExpReplace("Where have all the flowers gone, long time passing?", "[aeiou]", "@") & @CRLF
$text = $text & "Error: " & @error & @CRLF
$text = $text & "Extended: " & @error & @CRLF

MsgBox(0, "Regular Expression Replace Test", $text)

What does it return?

EDIT: Code...

Edited by Bert
Link to comment
Share on other sites

  • Moderators

no, this might NOT help, because the problem is not missing knowledge about regular expressions but the incorrect documented returnvalue in the autoit-documentation.

thats wrong!

StringRegExpReplace returns NOT the errorcode but the replaced string.

You reply to a 5 month old post of mine like you're angry and have a point to prove? You'd better keep reading and learning about our regexp's!

@Bert... I appreciate your effort (you didn't show it returning an error code, and you're using @error for @extended) <_<

@OP

Flag = 0 :

@Error Meaning

2 Bad pattern.

So, because my "Expression PATTERN" is wrong below, I will get an error of 2!

$out = StringRegExpReplace("Where have all the flowers gone, long time passing?", "\", "@")
$text = $out & @CRLF
$text = $text & "Error: " & @error & @CRLF
$text = $text & "Extended: " & @extended & @CRLF

MsgBox(0, "Regular Expression Replace Test", $text)

Learn to read and comprehend before you go jumping after someone, especially after 5 freaking months!

Edited by SmOke_N

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.

Link to comment
Share on other sites

@Bert... I appreciate your effort (you didn't show it returning an error code, and you're using @error for @extended) <_<

Twas a long day at school... And little sleep the night before. And teachers on the prowl. I blame all of the above and more! :)
Link to comment
Share on other sites

> You reply to a 5 month old post of mine ...

yes. may be, because i run into the same problems with documentation, not with regexp, like MrTWist moth ago ? ;-)

> ... like you're angry and have a point to prove?

does it sound so? :) sorry! <_<

> You'd better keep reading and learning about our regexp's!

again: knowledge about regular expressions is not the point. autoit-regexp-syntax is the same as in perl. nothing new (4 me).

$out = StringRegExpReplace("Where have all the flowers gone, long time passing?", "\", "@")

StringRegExpReplace returns the replaced string

@error will be set to the number of errors

@extended will be set:

on success to the number of replacements

on error the offset of error in pattern

have a look at "StringReplace", this ("Returns the new string, the number of replacements performed is stored in @extended.") is a useful description of returnvalue and additional parameters, stored at different places.

it seams, somebody has simply copied it from other documentation-parts (StringRegExp) and has not exactly reviewed it.

the same on "FileSaveDialog". FileSaveDialog does not support selection of multiple files.

this part was copied from "FileOpenDialog", witch supports it, but for "FileSaveDialog" this statement is wrong.

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Link to comment
Share on other sites

  • Moderators

> You reply to a 5 month old post of mine ...

yes. may be, because i run into the same problems with documentation, not with regexp, like MrTWist moth ago ? ;-)

> ... like you're angry and have a point to prove?

does it sound so? :) sorry! <_<

> You'd better keep reading and learning about our regexp's!

again: knowledge about regular expressions is not the point. autoit-regexp-syntax is the same as in perl. nothing new (4 me).

StringRegExpReplace returns the replaced string

@error will be set to the number of errors

@extended will be set:

on success to the number of replacements

on error the offset of error in pattern

have a look at "StringReplace", this ("Returns the new string, the number of replacements performed is stored in @extended.") is a useful description of returnvalue and additional parameters, stored at different places.

it seams, somebody has simply copied it from other documentation-parts (StringRegExp) and has not exactly reviewed it.

the same on "FileSaveDialog". FileSaveDialog does not support selection of multiple files.

this part was copied from "FileOpenDialog", witch supports it, but for "FileSaveDialog" this statement is wrong.

@error will be set to the number of errors

This isn't true. It specifically says that if there is no error that 0 is returned for the value of @error, and the only other error returned is a bad expression error which is the value of 2 for @error.

Return Value

@Error Meaning

0 Executed properly. Check @Extended for the number of replacements performed.

2 Pattern invalid. @Extended = offset of error in pattern.

I'm not quite sure what you are reading ... but you can't read to much into that small return value quote from the help file (Or maybe you can?).

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.

Link to comment
Share on other sites

This isn't true. It specifically says that if there is no error that 0 is returned for the value of @error, and the only other error returned is a bad expression error which is the value of 2 for @error.

ok, you're right and i'm wrong on this point:

on success

@error will be set to 0

@extended will be set to the number of replacements

on error

@error will be set to 2

@extended will be set to the offset of error in pattern

but whats with the returnvalue of StringRegExpReplace?

Return Value

on success

Returns a String with replacements performed

@error will be set to 0

@extended will be set to the number of replacements

on error

Returns the unchanged String

@error will be set to 2

@extended will be set to the offset of error in pattern

should this not be included?

and whats with "FileSaveDialog"?

am i right or am i wrong with "FileSaveDialog does not support selection of multiple files." ?

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Link to comment
Share on other sites

  • Moderators

ok, you're right and i'm wrong on this point:

but whats with the returnvalue of StringRegExpReplace?

should this not be included?

and whats with "FileSaveDialog"?

am i right or am i wrong with "FileSaveDialog does not support selection of multiple files." ?

I suppose it could tell you that... but I mean come on... Isn't it obvious that you either get the original string if no match was found and replaced, or the replaced string if there was a match found? I mean... why else would you use StringRegExpReplace?

....

The filesavedialog... how/why would you want to save the same file under multiple names?

Edited by SmOke_N

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.

Link to comment
Share on other sites

I suppose it could tell you that... but I mean come on... Isn't it obvious that you either get the original string if no match was found and replaced, or the replaced string if there was a match found? I mean... why else would you use StringRegExpReplace?

this is not a private collection of post it's but a official documentation and i think, it should as exact, as possible.

i use php too, and preg_match for instance does not return a string but the matches-count. the matches will be stored in a variable, witch it awaits as parameter.

what i want to say is: it is not to take for granted, that any function returns its processed data. else MrTWist and me won't run in the same problems.

dont think about you (and me <_< ), think about the people, witch start programming the first time and have not the practical experience, to guess this implicit behavior.

The filesavedialog... how/why would you want to save the same file under multiple names?

thats my question too :P , but i had not written in the documentation, that it supports such funny behavior. :) and: it doesn't, so fix this in the documentation ;-)

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Link to comment
Share on other sites

  • Moderators

this is not a private collection of post it's but a official documentation and i think, it should as exact, as possible.

i use php too, and preg_match for instance does not return a string but the matches-count. the matches will be stored in a variable, witch it awaits as parameter.

what i want to say is: it is not to take for granted, that any function returns its processed data. else MrTWist and me won't run in the same problems.

dont think about you (and me <_< ), think about the people, witch start programming the first time and have not the practical experience, to guess this implicit behavior.

thats my question too :P , but i had not written in the documentation, that it supports such funny behavior. :) and: it doesn't, so fix this in the documentation ;-)

To answer both questions... There aren't going to be updates of the obvious more than likely.

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.

Link to comment
Share on other sites

To answer both questions... There aren't going to be updates of the obvious more than likely.

i am from germany, my english is limited. may be, i misunderstood some things.

is this right?

obvious(*) wrong descriptions and obvious(*) incomplete descriptions in a technical documentation aren't more than likely worth to be rectified?

(*) "obvious" for whom? for novices too?

Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

Link to comment
Share on other sites

  • Moderators

i am from germany, my english is limited. may be, i misunderstood some things.

is this right?

obvious(*) wrong descriptions and obvious(*) incomplete descriptions in a technical documentation aren't more than likely worth to be rectified?

(*) "obvious" for whom? for novices too?

You're just nit picking.

I've pointed out you're examples are wrong, showed how and why, yet you persist on keeping this going.

IMHO, there are examples in the Help file, and examples on the forum, as well as an opportunity for help on the forum at no cost to you, if you can't figure out the Obvious (* after running the example(s), you actually see what it does), or asking your question on the forum and analyzing the answers received, then you probably don't need to be using any language.

In the couple of years I've read up on the programming world, I've not found a more helpful help file... I've also come to this conclusion after viewing many different languages.

Common sense is not a luxury, it's a necessity.

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.

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...