开发者

Need Regular Expression pattern for validating path directory structure in Flex?

I need a regular expression pattern for validating the following path di开发者_运维技巧rectory:

"C:/SomeDefaultPath/Input/swift/*.pdf"

and

"../Input/swift/*.pdf"

I've tried the regexp pattern got from net search, but I couldn't validate the above mentioned paths.

Any help would be appreciable.

Thanks in advance, Marshal.


Try this:

new RegExp("^(([a-z]:)|\\.\\.)([\\\\/][^\\\\/:*?\"<>|\r\n]+)*[\\\\/]\\*\\.[a-z]*$", "im")

You can test it with the following simple application:

<?xml version="1.0" encoding="utf-8"?>
<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" minWidth="955" minHeight="600">
    <fx:Script>
    <![CDATA[
        [Bindable]
        private var expString:String = "^(([a-z]:)|\\.\\.)([\\\\/][^\\\\/:*?\"<>|\r\n]+)*[\\\\/]\\*\\.[a-z]*$";
    ]]>
    </fx:Script>
    <fx:Declarations>
        <mx:RegExpValidator flags="im" expression="{expString}" source="{pathInput}" property="text" id="pathValidator" />
    </fx:Declarations>
    <s:TextInput id="pathInput" verticalCenter="0" horizontalCenter="0" change="pathValidator.validate()" />
</s:Application>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜