Sign in to follow this  
Followers 0
JLogan3o13

StringRegExpReplace assistance

6 posts in this topic

#1 ·  Posted (edited)

I am hoping someone who does a lot more with StringRegExp can assist with this, as it makes my eyes bleed. I am trying to strip the OU, CN, DC and = (but leave the commas) from an FQDN for a container in A.D. An example of the pattern is below, thus far I've tried a couple of things but am not getting the expected result.

Pattern : OU=Non-Citrix Production ,OU=XenApp and Citrix Servers,OU=Citrix,DC=my,DC=domain

Desired Outcome : Non-Citrix Production ,XenApp and Citrix Servers,Citrix,my,domain

The closest I have come is with something like this:

StringRegExpReplace($string, "(?-i)[DC=CN=OU=]", "", 10)

That returns the following: on-itrix Production,XenApp and itrix Servers,U=Citrix,DC=my,DC=domain

Any suggestions are appreciated.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites



Maybe this?

$string = "OU=Non-Citrix Production\ ,OU=XenApp and Citrix Servers,OU=Citrix,DC=my,DC=domain"
$regex = StringRegExpReplace($string, "[OU|CN|DC]+=", "", 0)
Display($string, $regex)

Func Display($sInput, $sOutput)
; Format the output.
Local $sMsg = StringFormat("Input:\t%s\n\nOutput:\t%s", $sInput, $sOutput)
MsgBox(0, "Results", $sMsg)
EndFunc ;==>Display

Hi!


My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites

Try this.

$string = "OU=Non-Citrix Production\ ,OU=XenApp and Citrix Servers,OU=Citrix,DC=my,DC=domain"

ConsoleWrite(StringRegExpReplace($string, "(OU=|CN=|DC=)", "") & @LF)

;Returns         : Non-Citrix Production\ ,XenApp and Citrix Servers,Citrix,my,domain
;Desired Outcome : Non-Citrix Production\ ,XenApp and Citrix Servers,Citrix,my,domain

Share this post


Link to post
Share on other sites

I'd do it like this

ConsoleWrite(StringRegExpReplace($Test, "(?-i)(?:DC|CN|OU)=", "", 10) & @CR)

with all the stuff you know, I'd have thought you could handle this :P

Share this post


Link to post
Share on other sites

$string = "OU=Non-Citrix Production\ ,OU=XenApp and Citrix Servers,OU=Citrix,DC=my,DC=domain"

MsgBox(64, "Result", "Input: "& $string & @CR & "Output: " & StringRegExpReplace($string, "(OU|CN|DC)=", ""))


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Thanks, all, for the suggestions. Unfortunately, SRE is something I've always shied away from, just makes my head hurt :)


√-1 2^3 ∑ π, and it was delicious!

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