Jump to content
UBot Underground

Recommended Posts

Under "parameters" there is a node called replace its under "text" and that will do it for you - that way you don't have to use regex.

 

If he only want's to replace the "X occurence"/"Xth match" I don't think that won't work for him, since this would replace all occurances (REGEX would do the same, if all matches and their pre/post-text is the same).

 

Tha't why I think you should try with "$find index" and "$substring"functions, and virtually split the text into multiple strings, then merge them back together after replace has been made.

 

It would go like this:

-get first occurance position and lenght (inside input text) with "$find index" function ;

-get the the first part of text and append it to output string with "$substring" function, where you set start position to 0 and lenght to the lenght you get with adding "$find index" position and lengt of "ubot studio";

-then set input string with "$substring" function, only this time you set starting postiion to the lenght you get with adding "$find index" position and lengt of "ubot studio" and ending position to total lenght of input string (this way you remove first part of string which was already moved to output string)

-do operation above until you reach the occurance you want to replace, and when moving it make a replacement (replace "ubot studio" with "ubot software").

-append the rest of the input string to output string

 

This way you should get over the whole string and only replace the occurance you want.

 

Hopefully it makes sense.

Link to post
Share on other sites

Under "parameters" there is a node called replace its under "text" and that will do it for you - that way you don't have to use regex.

 

Thank you HelloInsomnia. This way will replace all text so it's not work for me.

Link to post
Share on other sites

If he only want's to replace the "X occurence"/"Xth match" I don't think that won't work for him, since this would replace all occurances (REGEX would do the same, if all matches and their pre/post-text is the same).

 

Tha't why I think you should try with "$find index" and "$substring"functions, and virtually split the text into multiple strings, then merge them back together after replace has been made.

 

It would go like this:

-get first occurance position and lenght (inside input text) with "$find index" function ;

-get the the first part of text and append it to output string with "$substring" function, where you set start position to 0 and lenght to the lenght you get with adding "$find index" position and lengt of "ubot studio";

-then set input string with "$substring" function, only this time you set starting postiion to the lenght you get with adding "$find index" position and lengt of "ubot studio" and ending position to total lenght of input string (this way you remove first part of string which was already moved to output string)

-do operation above until you reach the occurance you want to replace, and when moving it make a replacement (replace "ubot studio" with "ubot software").

-append the rest of the input string to output string

 

This way you should get over the whole string and only replace the occurance you want.

 

Hopefully it makes sense.

 

Thank you UBotDev.com. i will try your way as soon as possible.

Let me descripe you the detail step by step

 

My task is:

1. Open a .txt file

2. Find the word "ubot studio"

3. Replace it with "ubot software" when only 4th or 5th or 6th .... match occurence of "ubot studio" keyword (will be replace once, 4th or 5th or 6th, not replace all them)

4. save a new .txt file after replace content

 

That's all. Thank you very much.

I will appreciate your way.

Link to post
Share on other sites

If he only want's to replace the "X occurence"/"Xth match" I don't think that won't work for him, since this would replace all occurances (REGEX would do the same, if all matches and their pre/post-text is the same).

 

Tha't why I think you should try with "$find index" and "$substring"functions, and virtually split the text into multiple strings, then merge them back together after replace has been made.

 

It would go like this:

-get first occurance position and lenght (inside input text) with "$find index" function ;

-get the the first part of text and append it to output string with "$substring" function, where you set start position to 0 and lenght to the lenght you get with adding "$find index" position and lengt of "ubot studio";

-then set input string with "$substring" function, only this time you set starting postiion to the lenght you get with adding "$find index" position and lengt of "ubot studio" and ending position to total lenght of input string (this way you remove first part of string which was already moved to output string)

-do operation above until you reach the occurance you want to replace, and when moving it make a replacement (replace "ubot studio" with "ubot software").

-append the rest of the input string to output string

 

This way you should get over the whole string and only replace the occurance you want.

 

Hopefully it makes sense.

 

 

Ah sorry, I misread the original post.

 

Dear All

 

Here is my extend request for this.

 

I have a content text. I want to find the string 'Ubot Studio' and replace it with 'Ubot Software', it must be replaced at n match occurrence. After replaced, show the result all.

 

I just create a test bot. Can you all please to see what wrong with it. I can not get the result i want.

set(#content, "Unlike other clunky, bloated automation suites, UBot Studio has a clean, simple, drag-and-drop interface that works with you, not against you, allowing point-and-click automation on any website, without requiring you to become a programmer to use it.

No other automation software lets you simply click the “Compile” button and create stand-alone bots that work on any computer – without limitations. UBot Studio keep these executable files, give them out, or sell them, and find a new revenue stream instantly.

UBot Studio can look at a website the way a human does, and actually “see” and automate pages like Flash applets, Java applets, Movie Player Applets, ActiveX controls or any other technology.

UBot Studio can read RegEx and Javascript, so programmers will save hours by using their coding knowledge to write quick solutions in Javascript and the .NET regular expression engine!

Ubot Studio is awesome, it really is a hidden gem. One of the only products I highly recommend.", "Global")
set(#find, "Ubot Studio", "Global")
set(#replace, "Ubot Software", "Global")
set(#match, 3, "Global")
set(#result, $replace regular expression(#content, "((#find(\\n|.)*?){#match})#find", "$1#replace"), "Global")
ui stat monitor("", #result)

So can you all please help me once again? 

 

Thanks and Best regards

Link to post
Share on other sites

Dear All

 

Here is my extend request for this.

 

I have a content text. I want to find the string 'Ubot Studio' and replace it with 'Ubot Software', it must be replaced at n match occurrence. After replaced, show the result all.

 

I just create a test bot. Can you all please to see what wrong with it. I can not get the result i want.

set(#content, "Unlike other clunky, bloated automation suites, UBot Studio has a clean, simple, drag-and-drop interface that works with you, not against you, allowing point-and-click automation on any website, without requiring you to become a programmer to use it.

No other automation software lets you simply click the “Compile” button and create stand-alone bots that work on any computer – without limitations. UBot Studio keep these executable files, give them out, or sell them, and find a new revenue stream instantly.

UBot Studio can look at a website the way a human does, and actually “see” and automate pages like Flash applets, Java applets, Movie Player Applets, ActiveX controls or any other technology.

UBot Studio can read RegEx and Javascript, so programmers will save hours by using their coding knowledge to write quick solutions in Javascript and the .NET regular expression engine!

Ubot Studio is awesome, it really is a hidden gem. One of the only products I highly recommend.", "Global")
set(#find, "Ubot Studio", "Global")
set(#replace, "Ubot Software", "Global")
set(#match, 3, "Global")
set(#result, $replace regular expression(#content, "((#find(\\n|.)*?){#match})#find", "$1#replace"), "Global")
ui stat monitor("", #result)

So can you all please help me once again? 

 

Thanks and Best regards

 

As I mentioned above I think UBot's REGEX won't allow you to make replacements you want (it will make similar replacement that "$replace" would), so you should try with the functions I've mentioned above.

Link to post
Share on other sites

If he only want's to replace the "X occurence"/"Xth match" I don't think that won't work for him, since this would replace all occurances (REGEX would do the same, if all matches and their pre/post-text is the same).

 

Tha't why I think you should try with "$find index" and "$substring"functions, and virtually split the text into multiple strings, then merge them back together after replace has been made.

 

It would go like this:

-get first occurance position and lenght (inside input text) with "$find index" function ;

-get the the first part of text and append it to output string with "$substring" function, where you set start position to 0 and lenght to the lenght you get with adding "$find index" position and lengt of "ubot studio";

-then set input string with "$substring" function, only this time you set starting postiion to the lenght you get with adding "$find index" position and lengt of "ubot studio" and ending position to total lenght of input string (this way you remove first part of string which was already moved to output string)

-do operation above until you reach the occurance you want to replace, and when moving it make a replacement (replace "ubot studio" with "ubot software").

-append the rest of the input string to output string

 

This way you should get over the whole string and only replace the occurance you want.

 

Hopefully it makes sense.

 

 

Dear UBotDev.com

 

It's now i understand your smart way to use $find index and $sub string. I'm very grateful to you. My problem solved now.

Thank you UbotDev.com very much. I love you.

 

Best Regards

Edited by blackhat04yr
Link to post
Share on other sites

Thanks, and no problem, glad you solved it (no need to love me :) ) .

 

I dealt with this a while ago, and it was the quickest way to solve it.

 

The problem with UBot REGEX is that ".*?" will break the match at first new line character, that's why you can0t use it like you wanted (there is no multiline option with UBot REGEX).

Link to post
Share on other sites

Thanks, and no problem, glad you solved it (no need to love me :) ) .

 

I dealt with this a while ago, and it was the quickest way to solve it.

 

The problem with UBot REGEX is that ".*?" will break the match at first new line character, that's why you can0t use it like you wanted (there is no multiline option with UBot REGEX).

 

Dear UBotDev.com

 

Thank you for a new experience with regular expression.  :)  I just thought it's will be very simple if we can use regular expression. I don't think UBot can't have multiline option. :D

Have a nice day UBotDev.com. I still love you too.

 

Thanks and Best Regards

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...