XML and Regular Expression and JavaScript.

Hi All,

This one is throwing me for a loop. It's just probably something simple I am missing and I'm not catching it.

I have an XML and in the XML I have like this node:

<File RegEx="^((([a-zA-Z]\:)|(\\))(((\\{1})[^\\\ ]([^/:*?<>""|\\]*))+)[\\]).*\.(?!xml$|tif$)[^.]+" Description="TEST File">

The node has an attribute for a regular expression.  The xml will get loaded in with Javascript.

Now, the problem I am having is on the regular expression: mainly with this part of the regular expression - ([^/:*?<>""|\\]*))+)[\\]). Notice the "".

The intent of the regular expression is to exclude files that ARE NOT an .xml or tif extension. This is where the part of the regular expression comes in. I need to be able to accommodate for either a letter:\ or a UNC. (C:\Test or \\XX.XX.XX.XX\Test).

One might think to just escape the quotes with a \"\". That didn't work. One might think to change the double quotes to single quotes ('") instead of (""). Well, did that and it didn't work either. When I have the escaped double quotes it is not a valid XML and cannot even really save it unless I open it in notepad and change it. BUT I cannot even open in as a straight XML in IE.

When I change it to a single quote, I am able to save it as an XML. However, I am still unable to open it in IE.

How can I do this? I tried to escape and that didn't work. I tried to change to single quotes and that didn't work.

Any positive information on this would greatly be appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Terry WoodsIT GuruCommented:
Try replacing it with &quot;

<File RegEx="^((([a-zA-Z]\:)|(\\))(((\\{1})[^\\\ ]([^/:*?<>&quot;|\\]*))+)[\\]).*\.(?!xml$|tif$)[^.]+" Description="TEST File">

Open in new window

davismAuthor Commented:
Nope, that doesn't work either. You cannot open it in IE. Let alone there are 2 quotes. So you would have to do &quot;&quot;

But I did one and then tried 2. Neither worked.
Terry WoodsIT GuruCommented:
Are you able to provide a stripped down sample file that I can try opening in IE myself?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

davismAuthor Commented:
Yeah, it you do something like this:

<?xml version="1.0" ?>

   <File RegEx="^.*\.(?!xml$|tif$)[^.]+" Description="TEST File">

If you put the above in a file then you can open the file in IE. Or if you just take the Test.xml file you will see you can.
Terry WoodsIT GuruCommented:
Looks like the < and > characters need escaping too:
<File RegEx="^((([a-zA-Z]\:)|(\\))(((\\{1})[^\\\ ]([^/:*?&lt;&gt;&quot;&quot;|\\]*))+)[\\]).*\.(?!xml$|tif$)[^.]+" Description="TEST File">

Open in new window

Ampersands would need escaping too, if used. More detail here: http://www.w3.org/TR/xml/#syntax

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
davismAuthor Commented:
Yep, that was it! Didn't think I have to specify the greater than and everything too. Go figure.

Thanks for the info and assistance.

Greatly appreciated!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.