Sign in to follow this  
Followers 0
Aceguy

Regexprepl

7 posts in this topic

#1 ·  Posted (edited)

Hi , having the smae old problem with stringregexpreplace....

this is the string:-

Lu. ace / try editOther UsesResale Price: ~1,292 - 1,420 edt

would like to filter out

words 4+ letter \w{4,}

any digit \d+

and any spaces \s*

but cant seem to combing the 2...

have tried (\w{4,})(\d+)(\s*)

(\w{4,})*(\d+)*(\s*)

Grrr

Edited by Aceguy

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$str = 'Lu. ace / try editOther UsesResale Price: ~1,292 - 1,420 edt'
 ConsoleWrite(StringRegExpReplace($str, '\\w{4,}|\\d', '') & @CRLF)

Mega

Edit : the f... code or Autoit tags remove the \. the pattern is = \w{4,}|\d

Edit 2 : I escaped the \ by another \ :)

Edited by Xenobiologist

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

#3 ·  Posted (edited)

#include <Array.au3>

Dim $sStr = "Lu. ace / try editOther UsesResale Price: ~1,292 - 1,420 edt"
Dim $sPatt = "\\b(?:\\w{4,}|\\d[\\d,]{3,})\\b"
Dim $aMatches = StringRegExp($sStr, $sPatt, 3)

If IsArray($aMatches) Then _ArrayDisplay($aMatches)

The thousands separated numbers is a bit problematic but you can come up with a patter that match thousands separated number strings that it at least 1,000 and bigger.

Edited by Authenticity

Share this post


Link to post
Share on other sites

Hi,

no the | means or which in this case is no problem cause both sides should be replaced by "" (emtpy string).

So, the pattern looks for letters included _ with length 4 or higher OR any digit and replaces them with nothing.

Mega

P.S.: If the numbers within a , or. or both should be completly replaced then you need to expand the pattern a little bit.


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

so to remove the ~-:, chars |[~-:,] err no, lol...

GRR

why not?

$str = 'Lu. ace / try editOther UsesResale Price: ~1,292 - 1,420 edt'
ConsoleWrite(StringRegExpReplace($str, '\\w{4,}|\\d|[-~:,]', '') & @CRLF)

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

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