tsue

Cleaner code?

7 posts in this topic

#1 ·  Posted

hello, i was wondering if there is a better way or a cleaner way to do this with relguar expressions

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

$line = '<input type="checkbox" name="answers[b]" class="optInput" id="answers_b" />                                    <pre class="np">text/plain</pre>'



$strLetterLeft = 'name="answers['
$strLetterRight = ']"'

$findletter = StringRegExp($line, '\Q' & $strLetterLeft & '\E' & "(.*?)" & '\Q' & $strLetterRight & '\E' , 3, 1)
For $i = 0 To UBound($findletter) - 1
        $strAnswerLeft = '<pre class="np">'
        $strAnswerRight = '</pre>'

        $findanswer = StringRegExp($line, $strAnswerLeft & "(.*?)" & $strAnswerRight , 3, 1)
        For $i = 0 To UBound($findanswer) - 1

            $stringrep2 = StringRegExpReplace($line, '<([^%]*?)/pre>', '<b>' & StringUpper($findletter[0]) & '.</b> ')
            $varStringFinal = $stringrep2 & '<span class="np">' & $findanswer[0] & '</span>'
            MsgBox(0, "replaced", $varStringFinal)
        Next
Next

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

They already are regular expressions...

 


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

#3 ·  Posted

On 6/1/2017 at 3:55 PM, careca said:

They already are regular expressions...

 

my bad i mean keeping regular expressions in the code. just to make the coding better or cleaner like a pro coder will do

Share this post


Link to post
Share on other sites

#4 ·  Posted

Im not a pro coder, so i cannot help. Code seems good enough to me. XD


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

Maybe have a look at the Best Coding Practices :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
6 hours ago, TheDcoder said:

Maybe have a look at the Best Coding Practices :)

wow what a great page thanks :)

Share this post


Link to post
Share on other sites
27 minutes ago, tsue said:

wow what a great page thanks :)

My pleasure :D.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
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