Jump to content

create a regex not to include text


Go to solution Solved by Nine,

Recommended Posts

i have a word frequency counter script. the problem is that it counts 1 letter words and numbers

i need the script to list only 2 or more letter words with no numbers

 

#Include <Array.au3>
#Include <Debug.au3>
#include <Constants.au3>
#include <AutoItConstants.au3>

Example()

Func Example()
$s = FileRead("2.txt")
ProgressOn ( "Word Frequency", "Counting", "Loading", Default, Default, 18 )
Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3)
_ArrayColInsert($w, 1)
For $i = 0 to UBound($w)-1
   ProgressSet (( $i/(UBound($w) - 1)) * 100, "processed", "word frequency" )
   StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0])
   $w[$i][1] = @extended
Next
ProgressSet(100, "Done", "Complete")
_ArraySort($w, 1, 0, 0, 1)
_DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW)
; _DebugArrayDisplay($w, "Title", "|0:1")
; _DebugArrayDisplay($w, "Title", "|0:1", $ARRAYDISPLAY_NOROW)
$sMessage = ""
SplashTextOn("Counting words", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "")
For $i = 1 To $w
    $sMessage = $sMessage & $i & @CRLF
Next
ProgressOff()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

  • Solution

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