header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Powershell Beginner User Find and Replace Asterisk Problems
Last Post 22 Jul 2010 04:37 AM by jamesscott11. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
jamesscott11User is Offline
New Member
New Member
Posts:7
Avatar

--
22 Jul 2010 03:13 AM
    Hello all,

     I'm totally new to powershell and have the problem detailed below. I've tried Googling round for the answer to this problem, and am not sure if the answer is so simple it simply doesn't rank, or this is in fact more difficult than it looks.\s

     What I'm trying to do is strip the values from a dynamic XML file, so I can then dedupe the values and output a tailor made schema to upload to SQL server. Obviously the structure and dynamic nature of the file make using something saner impossible without the schema. I have posted the code and a sample of the XML below, but what I would like to achieve is replacing everything between and including the double quotation marks. To achieve this I was using a find and replace, where the find looked like this: "=`"*`"\s" and replace with this: =

    The hope being to turn something similar to this:






    Into this:






    Except it doesn't. Below is the code, any help would be much appreciated.
    Thanks,

    James

    George HowarthUser is Offline
    Basic Member
    Basic Member
    Posts:360
    Avatar

    --
    22 Jul 2010 04:27 AM
    Your XML got parsed, add it as an attachment instead.
    jamesscott11User is Offline
    New Member
    New Member
    Posts:7
    Avatar

    --
    22 Jul 2010 04:37 AM
    Hi All

    GWHowarth88 - many thanks for the pointer.

    Finally I located the problem in the regex, it should have looked more like this:

    (Get-Content XMLSchemaTestData.xml) |
    Foreach-Object {$_ -replace '("[^"\r\n]*")', "="} |
    Set-Content XMLSchemaTestData.xml

    Now it works,

    Regards,

    James
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer