Jump to content

Need help with StringRegExpReplace


Gleemax
 Share

Recommended Posts

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.

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

Link to comment
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
; ....
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...