Sign in to follow this  
Followers 0
gimx

[Solved] StringReplace and []

7 posts in this topic

#1 ·  Posted (edited)

Hello,

I have a string with [] (bracket in english ?).

I want remove this [] but i have an error.

What's wrong plz ? :D

$text = 123[456]789

$text = StringReplace($text, "[", "")

$text = StringReplace($text, "]", "")

Thx :D

Edited by gimx

Share this post


Link to post
Share on other sites



You must have quotes around the first string.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Sorry, I forget them when i wrote the post, but they are in my script.

$text = "123[456]789"

$text = StringReplace($text, "[", "")

$text = StringReplace($text, "]", "")

Share this post


Link to post
Share on other sites

Ok i've seen my prob.

For example, my "real" string is : 12[34]5(67)89

First, i want delete all digit between the (), the result would be : 12[34]589

And after, i want to delete the [].

I try this code but it don't work for the first case :

$text = StringRegExpReplace($text, "((.*?))", "")

Thx for help :D

Share this post


Link to post
Share on other sites

Hi,

try this:

Global $str = "12[34]5(67)89"
ConsoleWrite(StringRegExpReplace($str, '\(.*?\)|\[|\]', '') & @CRLF)

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

Aaahhh yes sorry, damn escaped char...

I didn't know we can add multiple pattern with | char.

Thx Xeno :D

Share this post


Link to post
Share on other sites

Aaahhh yes sorry, damn escaped char...

I didn't know we can add multiple pattern with | char.

Thx Xeno :D

| is an OR

Glad I could help.

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  
Followers 0