Jump to content

Regexprepl


Recommended Posts

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
Link to comment
Share on other sites

$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

Link to comment
Share on other sites

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

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

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