Check string for two special characters back to back

Hey all so I need to check if a string has 2 backslashes back to back ("\\"). So the string "\\computername\c$\file" would match but the string "C:\file\path" would not. I've tried contains, match, and like. I've tried the code
below which does work but gives me a false positive when I have a string like this "\computername\file\path".
$com = "\\computername\C$"
if($com -match "\\"){
Write-Host true
}else{
Write-Host false
Thanks for any help!

In Regex ^ matches the starting position of a string. \ is a special character in Regex so you need to escape it with another \, so since you want double backslash \\, you need to escape twice \\\\, so ultimately ^\\\\ reads, at the start of the string
 find \\
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
Don't Retire Technet

Similar Messages

  • RegExp for excluding special characters in a string.

    Hi All,
    Im using Flex RegExpValidator. Can anyone suggest me the correct expression to validate this condition?....
    I have tried this expression :----- /^[^///\/</>/?/*&]+$/...But in this it is also negating the alphabets.Also I have tried with opposite condition that in the String we should have alphabets and the expression is:-- ([a-z]|[A-Z]|[0-9]|[ ]|[-]|[_])*..... Please can anyone help me on this.
    Thanks in advanced to all.
    Munira

    sorry but you are posting things back that do not make any sense
    what do you mean with the below comment?
    munira06 wrote:
    Yes you are correct ,but I have tried this with single special character
    say
    Re: RegExp for excluding special characters in a string.
    here is a sample app taken from the live docs
    using ^[a-zA-Z0-9 \-_]*$ as the regex accepts all characters from a-z, A-Z, 0-9 - [space] and_
    run the example tell me what regex you are using and what test strings fail when they should pass or pass when they should fail
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Simple example to demonstrate the RegExpValidator. -->
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Script>
            <![CDATA[
                import mx.events.ValidationResultEvent;
                import mx.validators.*;
                // Write the results to the
                private function handleResult(eventObj:ValidationResultEvent):void {
                    if (eventObj.type == ValidationResultEvent.VALID) {
                        // For valid events, the results Array contains
                        // RegExpValidationResult objects.
                        var xResult:RegExpValidationResult;
                        reResults.text = "";
                        for (var i:uint = 0; i < eventObj.results.length; i++) {
                            xResult = eventObj.results[i];
                            reResults.text=reResults.text + xResult.matchedIndex + " " + xResult.matchedString + "\n";
                    } else {
                        reResults.text = "";
            ]]>
        </fx:Script>
        <fx:Declarations>
            <mx:RegExpValidator id="regExpV"
                    source="{regex_text}" property="text"
                    flags="g" expression="{regex.text}"
                    valid="handleResult(event)"
                    invalid="handleResult(event)"
                    trigger="{myButton}"
                    triggerEvent="click"/>
        </fx:Declarations>
        <s:Panel title="RegExpValidator Example"
                width="75%" height="75%"
                horizontalCenter="0" verticalCenter="0">
            <s:VGroup left="10" right="10" top="10" bottom="10">
                <s:Label width="100%" text="Instructions:"/>
                <s:Label width="100%" text="1. Enter text to search. By default, enter  a string containing the letters ABC in sequence followed by any digit."/>
                <s:Label width="100%" text="2. Enter the regular expression. By default, enter ABC\d."/>
                <s:Label width="100%" text="3. Click the Button control to trigger the validation."/>
                <s:Label width="100%" text="4. The results show the index in the text where the matching pattern begins, and the matching pattern. "/>
                <mx:Form>
                    <mx:FormItem label="Enter text:">
                        <s:TextInput id="regex_text" text="xxxxABC4xxx" width="100%"/>
                    </mx:FormItem>
                    <mx:FormItem label="Enter regular expression:">
                        <s:TextInput id="regex" text="ABC\d" width="100%"/>
                    </mx:FormItem>
                    <mx:FormItem label="Results:">
                        <s:TextInput id="reResults" width="100%"/>
                    </mx:FormItem>
                    <mx:FormItem >
                        <s:Button id="myButton" label="Validate"/>
                    </mx:FormItem>
                </mx:Form>
            </s:VGroup>
        </s:Panel>
    </s:Application>

  • Print preview for the special characters / symbols

    While displaying print preview / taking print output using QGA3 Transaction with developed Z SAPScript form specified as one of the parameters(say for example ZARMEXP), the special characters / symbols  like u2018∆u2019 are displayed as u2018#u2019 in the print preview / print output . Of course similar problem had existed for Lambda Symbol u2018u03BBu2019., but it was resolved by using the font type Helve_I7. But for the symbol u2018∆u2019 we checked with almost all the fonts that were available in the system, but of not much use. Hence could you kindly provide us solution(s) that would resolve this issue.

    Hi ,
    Can you please check language are installed properly in sap  check with basis people. then try to print it will work.
    when ever language are not maintin properly , the characters  or symbols are not print properly.
    Regars,
    Munibabu.k

  • Strategies for escaping special characters.

    Hi all,
    Our app(built using Workshop) needs to have a generic way of scrubbing special
    characters that a user might enter in the UI,and which might cause our sql that
    queries the DB to become malformed. To explain further,some of our DB controls
    are not using PreparedStatements to set Strings..instead, we are constructing
    the sql as a java string like:
    String myQuery="Select * from * where TOUPPER(name) like"+param.ToUpperCase().
    and then we do:
    Statement stmt=conn.createStatement();
    stmt.executeQuery(myQuery).
    In such cases, Oracle JDBC driver does not escape any special chars in the String
    param,and fails.Other than converting all our queries to use PreparedStatements,
    is there a generic pattern/Util class(mebbe RequestUtils) or some way of using
    the Servlet Filter API to scrub out any special chars that are input by the user?
    Thanks in advance.
    Vik.

    ServletFilter is the way to go on this one. Don't think there is anything built
    into Servlet spec that handles these characters, however, there are a number of
    sample filters that do such a task. I think there is a sample in either the O'Reilly
    book on Servlets or Core Servlets.
    "Vik" <[email protected]> wrote:
    >
    Hi all,
    Our app(built using Workshop) needs to have a generic way of scrubbing
    special
    characters that a user might enter in the UI,and which might cause our
    sql that
    queries the DB to become malformed. To explain further,some of our DB
    controls
    are not using PreparedStatements to set Strings..instead, we are constructing
    the sql as a java string like:
    String myQuery="Select * from * where TOUPPER(name) like"+param.ToUpperCase().
    and then we do:
    Statement stmt=conn.createStatement();
    stmt.executeQuery(myQuery).
    In such cases, Oracle JDBC driver does not escape any special chars in
    the String
    param,and fails.Other than converting all our queries to use PreparedStatements,
    is there a generic pattern/Util class(mebbe RequestUtils) or some way
    of using
    the Servlet Filter API to scrub out any special chars that are input
    by the user?
    Thanks in advance.
    Vik.

  • How to validate string that contains special characters.

    Hi,
    I am new to Data Services.I took excel sheet as a data source .Now i have do some validation functions like vendorgroup should not contain special characters ,name cleansing operations etc.. So,please anyone help me redarding this.
    Thanks in advance

    Anonymous,
    No this is not a bug. Working with multi-select lists or any item which stores colon delimited values can be tricky to work with in APEX. There are a few work arounds for this. One is to replace the colons with something else like you described and then replace the colons on the landing page. Another solution is to send the primary key for that record and have an automatic row fetch or a computation pull the colon delimited value.
    Cheers,
    Tyson Jouglet

  • Comp logs in for two seconds, then automatically logs back out.

    Ok. This is a strange one for me, and I can't seem to find any information online about it, or anyone who has had a similar problem. I caused the problem by trying to get my router to work, consequentially force-rebooting my eMac about three times in a row immediately after start-up. The final time I rebooted, I came to the login screen, and logged into my administrator account as usual. The desktop loaded for two seconds, and I even had enough time to get nethack in the early stages of starting up, then it went blue, and returned me to the login screen.
    Every time I try to log into my administrator account, it accepts my password just fine, loads my desktop background, items, and user settings, and then it just forces me immediately back to the login screen. I can log into my guest account just fine, use the internet, and do whatever over there, but it just wont let me into my administrator account. Or rather, it will, but only for (literally) one second. What happened? I didn't install anything recently, and the only thing I can think of that would of caused it would be all of the force re-booting (by just holding the power button down until it rebooted) that I did three startups in a row, maybe a minute after booting.
    HELLLP

    Force reboots can cause directory corruption.
    Try using Disk Utility to do a Disk Repair, as shown in this link, while booted up on your install disk.
    You could have some directory corruption. Let us know what errors Disk Utility reports and if DU was able to repair them.
     Cheers! DALE

  • Regexp for exclude special characters

    hi!
    i need a regular expression, which allows all chars and digits [A-Za-z0-9], without special characters like []@.
    anyone can help me? thx!
    bye,
    christian

    Hello Christian,
    first throw of mine would look like something of this:
    ^[A-Za-z0-9]*$^ gives you the start
    $ gives you the ending
    * gives you zero or more repititions. You can replace this with {min,max}, which gives you a minimum and maximum length.
    If you would like to know more about regular expressions this link might be useful for you.
    Regards,
    Tine

  • I was on YouTube while charging my MacBook Pro I left for two mins when I came back it was turned off and the charging cord was blinking green and orange now I can't turn my Mac book back on

    I Have a MacBook Pro 13-inch LED-backlit widescreen notebook. I was watching YouTube while I was charging my laptop then I left the room for two mins while I was gone it turned off and the cord is blinking green and orange. What do I do?

    Ok, then you can start with the general Apple Support site:http://www.apple.com/support/contact/ or try the ExpressLane at https://expresslane.apple.com for support.

  • EBS Search String for two words separate by other characters

    Hi
    Is there a way to write a search string which will recognize two words in a string?
    For example :
    PAYPAL TRANSFER WTT489798709898BOOK
    I need a search string which will recognize PAYPAL and BOOK
    I have tried : (|)PAYPAL + BOOK( |$)    or (|)PAYPAL / BOOK( |$)but in the test it is not successfull.
    Any help is appreciation

    Hi
    Does SAP treat multiple record 88 lines on the EBS as one continuous line for a single 16 record?
    I used the string  ^PAYPAL ?*DOTCOM PARTNERS LP$ based on your suggestion and uploaded a EBS statement.
    The system did not post anything, even though in string test if I enter the follwowing line it displays correct results
    :PAYPAL TRANSFER 110403 522222222454W DOTCOM PARTNERS LP/
    Our EBS statement has the following data:
    16,169,20000,,,00000000000,/                                                  
    88,OTHER REFERENCE:IA0000122222222/                                             
    88,PAYPAL TRANSFER 110403 522222222454W DOTCOM PARTNERS LP/  
    Any advise is appreciated.
    Edited by: Kirti Bhardwaj on Jul 5, 2011 9:20 PM

  • Getting text between two special characters as a new line

    Hi all ,
    I hope some one can point me in the right direction or tell me if its possible or if there is a function that can do this in tsql. I have table with two fields in a table ORDERNUM,NARRATIVE. The values in the NARRATIVE field are some what like this (they
    come from a flat while and are delimited by a "^"). The examples are like :
    OREDERNUM NARRATIVE
    1234           ^Parcel shipped^picked^entry passed then returned back^white ford truck number 78455333^freight charges entered^parcel weight entered^parcel supervised^ticketsscannned^broken glass on
    floor^
    what i want to is seperate the text between the "^" as new line like
    1234 parcel shipped
    1234 picked
    1234 entry passed then returned back
    1234 white ford truck number 78455333
    Can anyone please help me, is there a way or can any one show me what function does this? SUBSTRING for sure is not an answer as there is no fixed length for this.
    Thanks
    SV

    CASE_NUMBER NARRATIVE
    000000GA ^000000G-A CHIEF OF POLICE 02-02-95 PGE 1^***BATCH RUN COPY***^INCIDENT: MOLEST OTHER^LOCATION: 00416 N COLORADO AV OTHER:^EI20^ATTENTION:^ SEX OFFENSE^NOTIFIED: 02-01-95 2300 HRS BY: OTHER INVEST 02-01-95 2305 HRS^ARRESTS: 00 INJURED: 00 DEAD: 00 VEH TOWED: 00 BEAT: B51^^PERSON 01^VICTIM-PERSON^STEVE WOOLBRIGHT NH/W/M/14/08-31-80^SUBPEONA: N^ADDRESS: 00416 N COLORADO AV^HOME-PHONE: 322-9249^^^NARRATIVE:^REPORT MADE FROM STATE 310 REPORT STATING ABOVE-LISTED SUBJECT^HAS BEEN SEXUALLY MOLESTED. INVESTIGATION REQUESTED.^^4725 POPCHEFF A P4687^^02-01-95 2025 HRS - WILDER EULA W3163 TAPE:02^^ 95.033 00:23-END OF REPORT-95.033 00:26^^^
    000718GB ^000718G-B ADDITION CHIEF OF POLICE 08-08-95 PGE 1^***BATCH RUN COPY***^INCIDENT: RECOVERED STOL. VEH PUBLIC STREET-ALLEY^LOCATION: PLAINFIELD,IN OTHER:^OCCURED: 04-01-93 TIME UNKNOWN EO11^ATTENTION:^ AUTO DESK AUTO THEFT WEST DISTRICT^NOTIFIED: 08-07-95 1600 HRS BY: OTHER INVEST 08-07-95 1600 HRS^ARRESTS: 00 INJURED: 00 DEAD: 00 VEH TOWED: 00 BEAT: OJ^^PERSON 01^OWNER/OPERATOR^DAVID FURMAN NH/W/M/ 08-20-57^DRIVERS LICENSE/SSN: 310702334^ADDRESS: 02495 AVON RD PLAINFIELD IN^HOME-PHONE: 838-0467^^^VEHICLE 01^PICKUP^BLACK 91 FORD F350 2DR^VIN: 2FTJW35G6MCA99397^DISPOSITION: RECOVERED^COMMENTS: OWNER RECOVERED VEHICLE IN 1993^^NARRATIVE:^ON 08/07/95, I RECEIVED A PHONE CALL FROM JAMES BEARD OF THE^^ -CONTINUED-^
    000718GB ^000718G-B ADDITION CHIEF OF POLICE 08-08-95 PGE 2^^NATIONAL INSURANCE CRIME BUREAU WHO STATED HE WAS DOING A^CHECK OF HIS RECORDS AND CAME ACROSS A VEHICLE THAT WAS^STOLEN ON 04/24/92, UNDER IPD CASE #00718GA. HE STATED HE HAD^SPOKEN TO THE INSURANCE COMPANY ON THIS CASE AND THEY STATED^THEY HAD PAID OFF ON THE VEHICLE AND SOLD THE VEHICLE BACK TO^THE OWNER. APPARENTLY THE PERSON REPORTING THE EVENT, DAVID^FURMAN, REPORTED HIS VEHICLE STOLEN ON 04/24/92, APPROXIMATELY^1 YEAR LATER HE WAS CONTACTED BY AN UNIDENTIFIED PERSON AND^TOLD HIM TO MEET HIM ON A CORNER IN THE INDIANAPOLIS AREA AND TO^GIVE THE MAN $5,000.00 AND HE WOULD GIVE HIM HIS TRUCK BACK.^MR. FURMAN HAD ALREADY BEEN PAID BY THE INSURANCE COMPANY^APPROXIMATELY $31,000.00 IN RESTITUTION FOR HIS VEHICLE.^MR. FURMAN THEN WENT TO THIS CORNER LOT AND MET WITH THIS^UNIDENTIFIED W/M AND PAID HIM $5,000 CASH. THE MAN THEN TURNED^THE 1991 PICKUP TRUCK OVER TO MR. FURMAN. MR. FURMAN THEN^SETTLED WITH THE INSURANCE COMPANY AND PAID THEM $19,000.00 AND^BOUGHT THE VEHICLE BACK FROM THE INSURANCE COMPANY AND IT IS^NOW TITLED TO HIM AND REGISTERED TO HIM. HOWEVER, AT NO^POINT DID MR. FURMAN OR THE INSURANCE COMPANY CONTACT THE^POLICE DEPARTMENT TO TAKE THE VEHICLE OUT OF THE SYSTEM AS^BEING STOLEN. THAT IS THE REASON FOR THE REPORT. THE VEHICLE^SHOULD BE REPORTED AS A RECOVERED AND RELEASED TO OWNER. DAMAGE^UNKNOWN.^^^^ -CONTINUED-^
    select TOP 214
    CASE_NUMBER,
    splitdata
    from
    SELECT F1.CASE_NUMBER,
    O.splitdata
    FROM
    SELECT *,
    cast('<X>'+replace(F.NARRATIVE,'^','</X><X>')+'</X>' as XML) as xmlfilter from [dbo].[CECASRPT] F
    )F1
    CROSS APPLY
    SELECT fdata.D.value('.','varchar(5000)') as splitdata
    FROM f1.xmlfilter.nodes('X') as fdata(D)) O
    )t
    where t.splitdata <> ''
    SV

  • Single Check created for two Vendor invoices via RFFOUS_C

    Hi All
    We run the program RFFOUS_C to generate check printing, our requirement is to print a single check for each invoice to a vendor. So if two invoices require payment, then two checks created.
    The system generates two Check numbers which can be seen in F110. However when reviewing the file, only one check number is printed against both invoices.
    Where else should I be looking for a setting that determines the check payments?
    Regards
    Gurprit

    Hi,
    In the vendor master, company code data, payment transaction tab, there is a setting for individual payment. If this is checked, a separate payment will be made for each invoice.
    There may be other solutions but this one is very simple.
    Hope this helps.
    Alicia

  • Check string for alpha numeric

    is there a direct way to check whether the string is alpha numeric?

    private boolean isAlphaNumeric(String str){
              boolean blnNumeric = false;
              boolean blnAlpha = false;
              char chr[] = null;
              if(str != null)
                   chr = str.toCharArray();
              for(int i=0; i<chr.length; i++){
                   if(chr[i] >= '0' && chr[i] <= '9'){
                        blnNumeric = true;
                        break;
              for(int i=0; i<chr.length; i++){
                   if((chr[i] >= 'A' && chr[i] <= 'Z') || (chr[i] >= 'a' && chr[i] <= 'z')){
                        blnAlpha = true;
                        break;
              return (blnNumeric && blnAlpha);
    Hope this would solve your problem

  • How can we handle for german special characters for EXCEL -----URGENT

    HI All,
    I have report like to display data in more than one operating unit like german,us,spain.... etc
    I used the xml version like
    <?xml version="1.0" encoding="ISO-8859-1"?>
    and
    <?xml version="1.0" encoding="ISO-8859-2"?>
    In the above versions I am able to view the output well,but problem with the german/Spain letters.
    in place of germna letters .. it is displaying somethign others
    eg: 1.NYMPHENBURGER STR. 14 MÜNCHEN BAYERN 80335 Germany
    in excel report it is showing as
    NYMPHENBURGER STR. 14; MÃ?NCHEN;BAYERN;80335;GERMANY
    I registred the template with English Language and terrritory as United States..
    Result: I am able to view the ouput without any issues
    Issue: displaying other characters in place of German/Spain letters
    The report has the Customer Ship To address and Short descriptions ..
    please how can we fix this isssue.. it is very urgent for me
    Thanks,
    HTH
    Edited by: user9135824 on Nov 29, 2010 5:07 AM

    Hi All,
    Any body can provide the solution for this.
    Thanks in Advance

  • Mail for Exchange - special characters (umlaut) in...

    Hi,
    I have several usernames with german umlaut-characters (ü, ä, ö, ß). These usernames are not able to logon within Mail for Exchange. Is there any hint?
    M4E 1.06
    E60 3.0633.09.04

    Do you mean that you can not enter the characters in the username field or that it just doesn't work when you do?
    Which language are you using the phone in? Which language is Mail for Exchange in?

  • Regex: check string for even number of a symbol

    Hi,
    for example "ass'asd'asd" is valid, but "asd'asd'asd'asd" is not, for symbol " ' ". I have tried every combination of \w, [...],',+ and nothing...
    Ideas?

    what is doing the %2 here, prome' ?If there are an even number of char symbol in String s, then s.length() - s.replace(""+symbol, "").length() will also be even. So that number mod 2 will equal zero (and return true).

Maybe you are looking for