regex
4 TopicsMultiple spaces in a regex
Hello folks. I was trying to write a regex that would detect Secret S E C R E T S e c r e t se C re T ie, 'secret', case-insensitive and possibly with spaces between the letters (manual kerning) When I use (?i)\bs[ ]?e[ ]?c[ ]?r[ ]?e[ ]?t\b Then the first two cases succeed and words like "secretive" or "nonsecret" are not detected (which is correct). I'm aware that I could probably also just do " ?" (space, question mark) as there is a single character in the set. I tried swapping the "?" question mark (zero or one occurrences) to an "*" asterisk (zero or many occurrences), "*?" asterisk, question mark (lazy zero or many occurrences) and then " {0,}" all of which work fine in regex101 but, at least in Exchange Online, they fail test three and four. Has anyone got any advice on what I might try for multiple spaces? Is Exchange swapping two spaces for a completely different character? Ta, TimSolved163Views2likes2CommentsCan I use regex in a DCR custom text logfile filepath?
Hi, I have about 50 servers attached to a DCR to collect a custom text log into a log analytics workspace custom table. Is it possible or if anyone has experience with using a regex filepath in the DCR situation? The logs are in the same format but paths differs slightly on each servers. There are two structures, but includes the servernames so we have 50 different filepaths: App Server c:\appserver\logs\<server Fully Qualified Name>\server\*.log App Portal c:\appportal\logs\<server Fully Qualified Name>\portal\*.log When I use static paths it works (there's a limit of 20 by the way). I have tried using the following regex filepath nothing comes in: c:\app(server|portal)\logs\SYS[a-zA-Z0-9]{4}wm[0-9]{2}.domain.net\(server|portal)\*.log Can someone confirm with me whether I can use regex in the filepath pattern in the DCR Data Source Tex log setup? If so, how do I get it to work please? Am I missing some escapes somewhere please? Many thanks in advance.124Views0likes1CommentNew Project - Regex on Project Name - Limit Special Characters
Greetings, I haven't been able to find any reference to this anywhere online... When creating a new Project in PoL/PWA, is there a way to apply RegEx to the 'Name' (Project Name) field? Basically: I would like to limit it to Alpha-Numeric, Spaces and Dashes...and definitely prevent '&' and brackets '()[]'. Either make it required or prevent 'finish' button (Create project) from functioning until it is valid. What might be a strategy to go about this validation? (Note: I am somewhat surprised this has never been discussed before...especially considering that PWA creates a sub-site & use the 'Name' field as the URL. Frankly, it is surprising that PWA even allows '&'.) Much appreciated, -TRSolved651Views0likes2CommentsRename file using Regex
Hello, I need to bulk rename files usgin regex. I'm very bad with regex 😕 Here is a simplified sample: ... $source = "blabla" $target = "blibli" $files = Get-ChildItem -file -path ".\Desktop\test" -Recurse .. foreach ($file in $files) { if($($file.Name).ToLower().contains($source)){ echo "$($file.Name) contains $source)"} else{ echo "$($file.Name) does NOT contain $source)" } Now I want to replace the echo lines with something similar to : $NewName = $_.Name -replace "regex syntax..." #I want to manage the fact that my file could be named blabla.txt but also 4141343blablaffjs.txt Rename-Item -Path $_.FullName -NewName $NewName This is where I need your help. Thank you.2.8KViews0likes3Comments