Jump to content
Sign in to follow this  
Qualitybit

[solved] RegExp hate me :(

Recommended Posts

Qualitybit

I have a string containing a long text. Within the text are scattered informations within several pairs of parantheses '()'. So I need only this one pair of parantheses, which NOT contains numbers or a '*'.

In short: I want the parantheses only containing letters and NOT the other parantheses containing letters, numbers or a '*'.

RegExp starts to hate me at the very early beginning, where I try at a first step to extract the whole pairs of parantheses...

EDIT - example:

1. design #1365 (72$) (*)

2. design #2437 (59$) (in stock)

3. design #3424 (29$) (*)

(* means not available at the moment)

for in ...

IF stringregexp ($row[$i], "magic regexp proof if "()" with only letters in it exist", 0) THEN

$avail[$ii] = $row[$i]

next

101011 :whistle:

Edited by Qualitybit

[font="Courier New"][center]Me vs. 127.0.0.1 =>> 0:2But I never give up! >:-][/center][/font]

Share this post


Link to post
Share on other sites
SmOke_N

I have a string containing a long text. Within the text are scattered informations within several pairs of parantheses '()'. So I need only this one pair of parantheses, which NOT contains numbers or a '*'.

In short: I want the parantheses only containing letters and NOT the other parantheses containing letters, numbers or a '*'.

RegExp starts to hate me at the very early beginning, where I try at a first step to extract the whole pairs of parantheses...

101011 :whistle:

An example string, the code you've attempted, and the output you desire (written) would make more sense then what you have.

Edit:

This is how I'm understanding your question:

#include <array.au3>
$sString = '(((abcd)))'
$aArray = StringRegExp($sString, '(?s)(?i)\(+(.*?)\)', 3)
_ArrayDisplay($aArray)
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
/dev/null

An example string, the code you've attempted, and the output you desire (written) would make more sense then what you have.

Edit:

This is how I'm understanding your question:

#include <array.au3>
$sString = '(((abcd)))'
$aArray = StringRegExp($sString, '(?s)(?i)\(+(.*?)\)', 3)
_ArrayDisplay($aArray)
I suggest this one ;-))

#include <array.au3>

$text = "Hi, I don't know how to (post) a proper (problem) description, thus (345) people have to guess what I'm talking about (f***)"
$regexp = "(\([^\*\d]*?\))"

$result = StringRegExp($text,$regexp,3)

_ArrayDisplay($result)

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites
SmOke_N

I suggest this one ;-))

#include <array.au3>

$text = "Hi, I don't know how to (post) a proper (problem) description, thus (345) people have to guess what I'm talking about (f***)"
$regexp = "(\([^\*\d]*?\))"

$result = StringRegExp($text,$regexp,3)

_ArrayDisplay($result)

Cheers

Kurt

Wouldn't it just be:
$regexp = '(?s)\(\w+\)'
?

Edit:

NVM, didn't notice that the area could have a "space" , I only read he wanted the areas with only regular characters.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Qualitybit

Wouldn't it just be:

$regexp = '(?s)\(\w+\)'
?
Problem solved!

THX to all contriputors!

101011 ...a few years aged


[font="Courier New"][center]Me vs. 127.0.0.1 =>> 0:2But I never give up! >:-][/center][/font]

Share this post


Link to post
Share on other sites
SmOke_N

Problem solved!

THX to all contriputors!

101011 ...a few years aged

I think this is more what you want if you want spaces as well.
$regexp = '(?s)\((\w+\s*)+\)'

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
/dev/null

Wouldn't it just be:

$regexp = '(?s)\(\w+\)'
?

Edit:

NVM, didn't notice that the area could have a "space" , I only read he wanted the areas with only regular characters.

what happens if the text contains some special characters, like !,;./: etc? Like this: "N/A"

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites
SmOke_N

what happens if the text contains some special characters, like !,;./: etc? Like this: "N/A"

SOL? :whistle:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
/dev/null

SOL? :whistle:

SOL?


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

\([^\*\$0-9]*\)

So long,

Mega


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
SmOke_N

SOL?

http://www.urbandictionary.com/define.php?term=sol

Edit:

Hi,

\([^\*\$0-9]*\)

So long,

Mega

That looks right mega... I'd do the (?s) though...
$regexp = '(?s)\([^\*\$\d]*\)'
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Xenobiologist

http://www.urbandictionary.com/define.php?term=sol

Edit:

That looks right mega... I'd do the (?s) though...

$regexp = '(?s)\([^\*\$\d]*\)'
HI,

matching newline. Maybe it can be useful. So what ... :whistle::lmao:

So long,

Mega


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
/dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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  

×