Jump to content
Sign in to follow this  
grham

StringRegExpReplace vs. StringRegExp (is this a feature ?)

Recommended Posts

grham

Hello,

maybe I don't see anything or I'm doing something wrong?

This is a pattern that matches - correctly - a comma (,) in a string

before a non white space character.

$Res = StringRegExp($String, '(,)(?:\H)', 3)

Non obstant I can't use the same pattern for StringRegExpReplace:

(HelpFile?)

This matches the comma (,) and "non capturing (?:\H)" (both of them)

$String = StringRegExpReplace($String, '(,)(?:\H)', ', ', 0)

I imagine a workaround to accomplish my goal (would not be so hard)

(replace all commas only before a non white space character with a comma + white space)

but could someone tell me, please, if it's a feature of StringRegExpReplace because I didn't find

anything "on the topic"?

Than you.

Edited by grham

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

sorry I don't get it. Which text did you try it on?

So long,

Mega

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
grham

Hi,

sorry I don't get it. Which text did you try it on?

So long,

Mega

For example:

$String = "Montag,Dienstag,Mittwoch, Donnerstag,Freitag,Samstag,Sonntag"

Try to put a whitespace after any comma with my "example" so that you don't get

two whitespaces between Mittwoch and Donnerstag. Not: ..., Mittwoch, 'white' 'white' Donnerstag, ..."

==> "Montag, Dienstag, M ...."

I know it can be done in a different way.

:)

Edited by grham

Share this post


Link to post
Share on other sites
Siao

Use normal group with backref then:

StringRegExpReplace($String, '(,)(\H)', ', \2', 0)


"be smart, drink your wine"

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

meinst du nicht

#include<Array.au3>
$String = "Montag,Dienstag,Mittwoch, Donnerstag,Freitag,Samstag,Sonntag"
$String = StringRegExpReplace($String, '(,)(?=\H)', ', ')
ConsoleWrite($String & @CRLF)

So long,

Mega

P.S.: Habe Samstag mal mit einem m geschrieben. :)


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
grham

Use normal group with backref then:

StringRegExpReplace($String, '(,)(\H)', ', \2', 0)

OK, I got it

This works exactly as expected

("lack" in my knowledge)

Siao: Thank you!

Mega: Ooops

(btw., ich bin nicht deutsch, Ich kenne Dich nur aus dem deutschen Forum,

spreche ein bisschen Deutsch)

Danke für "Samstag"!!!!! :)

Edited by grham

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

okay.

Youg got $String = "Montag,Dienstag,Mittwoch, Donnerstag,Freitag,Samstag,Sonntag"

what should it look like after the StringRegReplace ?

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
grham

Hi,

okay.

Youg got $String = "Montag,Dienstag,Mittwoch, Donnerstag,Freitag,Samstag,Sonntag"

what should it look like after the StringRegReplace ?

So long,

Mega

I'm sorry Mega (my fault)

your example Works as expected too!!!

(Entschuldigung) and Thank you Very much

Edited by grham

Share this post


Link to post
Share on other sites
Xenobiologist

I'm sorry Mega (my fault)

your example Works as expected too!!!

(Entschuldigung) and Thank you Very much

HI,

:) no problem (kein Problem)

Hatte mich schon gewundert, was du willst. I already wondered what you want to achieve.

Sprichst aber gutes deutsch!

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

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  

×