Sign in to follow this  
Followers 0
Gleemax

Need help with StringRegExpReplace

5 posts in this topic

Hi.

I can't seem to get this to work. I've been reading the forums and testing stuff and I still don't understand why it doesn't work.

#include <FF.au3>
#include <trimmer.au3>

_FFStart("about:blank","default",1,False)
$dict=ClipGet()

;Removes spaces before and after the string.
$dict=_ALLTRIM($dict)

;Split the string into words.
$dict2=StringSplit($dict," ")

Do
    _FFOpenURL("http://dictionary.reference.com/browse/" & $dict2[$n],True)
    If _FFSearch("No results found for " & $dict2[$n]) Then
        If _FFSearch("Did you mean ") Then
                        ;Need to get their suggested word. (Did you mean suggestedword?)
                        ;Doesn't work here!
            $tempstring=StringRegExpReplace(_FFReadText(),'Did you mean \b([a-zA-Z]+)\b\?','\1')
            $dict2[$n]=$tempstring
        Else
            $dict2[$n]=""
        EndIf
    EndIf
    $n=$n+1
Until $n>=UBound($dict2)

;Do something here

_FFQuit()

Any help would be appreciated.

Share this post


Link to post
Share on other sites



What is the initial string ans what should the string look like after RegExp? (I cannot run your script @work)


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

_FFReadText returns the entire webpage's text. I don't know if there's a more pratical/faster way to do it tho.

The final string should only be the suggested word, if there's any. Else it returns blank.

Share this post


Link to post
Share on other sites

Regex pattern works just fine on my system. However, I cannot run your script since I don't have FF.au3.


Hi ;)

Share this post


Link to post
Share on other sites

Hi.

I can't seem to get this to work. I've been reading the forums and testing stuff and I still don't understand why it doesn't work.

#include <FF.au3>
#include <trimmer.au3>

_FFStart("about:blank","default",1,False)
$dict=ClipGet()

;Removes spaces before and after the string.
$dict=_ALLTRIM($dict)

;Split the string into words.
$dict2=StringSplit($dict," ")

Do
    _FFOpenURL("http://dictionary.reference.com/browse/" & $dict2[$n],True)
    If _FFSearch("No results found for " & $dict2[$n]) Then
        If _FFSearch("Did you mean ") Then
                        ;Need to get their suggested word. (Did you mean suggestedword?)
                        ;Doesn't work here!
            $tempstring=StringRegExpReplace(_FFReadText(),'Did you mean \b([a-zA-Z]+)\b\?','\1')
            $dict2[$n]=$tempstring
        Else
            $dict2[$n]=""
        EndIf
    EndIf
    $n=$n+1
Until $n>=UBound($dict2)

;Do something here

_FFQuit()

Any help would be appreciated.

You can read the suggested word with:

; ...
If _FFSearch("Did you mean ") Then
  $tempstring=_FFXPath("//div[@class='dym']//a")
  $dict2[$n]=$tempstring
Else
; ....

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
Sign in to follow this  
Followers 0