RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Advanced Search

Keywords

Category

Minimum Rating

Results per Page

Search Results: 26 regular expressions found.

Change page:   |    Displaying page 1 of 2 pages; Items 1 to 20
Title Test Details Pattern Title
Expression
^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*:\";|/]+$
Description
Checks for a valid windows file name (Must be used with the case-insensitive option Checks that the file has at lease one char, does not contain any invalid characters and does not have a reserved word as a file name. "If you see a " in the regex replace it with a " character"
Matches
test.txt | test.jpg.txt | a&b c.bmp
Non-Matches
CON | .pdf | test:2.pdf
Author Rating: Not yet rated. Andre Van Der Merwe
Title Test Details Pattern Title
Expression
(.*\.([wW][mM][aA])|([mM][pP][3])$)
Description
Matches a file name to be either a .wma or .mp3 file. This can be used to check file uploads to make sure they are of a certain type. Substitute letters where appropriate for specific file types. To include more simply add logical 'or' (|) operator and append.
Matches
thisfile.mp3 | [email protected]
Non-Matches
whatever.exe | somethingelse.mpa | thisagain.wm3
Author Rating: Not yet rated. Pete Samwel
Title Test Details Pattern Title
Expression
^(([a-zA-Z]:|\\)\\)?(((\.)|(\.\.)|([^\\/:\*\?"\|<>\. ](([^\\/:\*\?"\|<>\. ])|([^\\/:\*\?"\|<>]*[^\\/:\*\?"\|<>\. ]))?))\\)*[^\\/:\*\?"\|<>\. ](([^\\/:\*\?"\|<>\. ])|([^\\/:\*\?"\|<>]*[^\\/:\*\?"\|<>\. ]))?$
Description
File Name Validator. Validates both UNC (\\server\share\file) and regular MS path (c:\file).
Matches
File.txt | c:\Blah\..\.\Blah Blah.Blah\File.txt | \\server\share\file.txt
Non-Matches
File.txt | c:\.File.txt | c:\.\.Blah\File.txt
Author Rating: The rating for this expression. Dmitry Borysov
Title Test Details Pattern Title
Expression
^[a-zA-Z0-9_\s-]+$
Description
This tests an input string for only a-z and A-Z and only allows underscores, hyphens and spaces. The purpose is to force users to generate legitimate, readable file names that can be streamed from the web.
Matches
123Testing | 123_Testing | 123-Testing This
Non-Matches
[email protected]#Testing | Testing &quot;This&quot; | Don't Forget to Write
Author Rating: The rating for this expression. Paul Fox
Title Test Details Pattern Title
Expression
/[^/]+$
Description
Very easy expression to get the file name from a path. I couldn't find it so I wrote it and now I post it here! Hope it could help.
Matches
/home/pietro/myfile.txt | /home/pietro/myfile
Non-Matches
/home/pietro/mydir/
Author Rating: Not yet rated. Pietro Bonfa
Title Test Details Pattern Title
Expression
^((?:[a-zA-Z]:)|(?:\\{2}\w[-\w]*)\$?)\\(?!\.)((?:(?![\\/:*?<>"|])(?![.\x20](?:\\|$))[\x20-\x7E])+\\(?!\.))*((?:(?:(?![\\/:*?<>"|])(?![ .]$)[\x20-\x7E])+)\.((?:(?![\\/:*?<>"|])(?![ .]$)[\x20-\x7E]){2,15}))?$
Description
Matches drives, folders and file on a Windows OS. Folder matches must end with \ Folder and file names can not end with a space. I limited the file extension length to 15 though that not a restriction of a file's extension This is a mod of Darren's regex http://www.regexlib.com/REDetails.aspx?regexp_id=357 and my own http://www.regexlib.com/REDetails.aspx?regexp_id=137 Updated Feb 2005
Matches
C:\ | \\Server\share\path\File.txt | E:\My Files\Are\#1\
Non-Matches
C: | C:\\\ | C:\Trailing Space \
Author Rating: Not yet rated. Michael Ash
Title Test Details Pattern Title
Expression
(?i:)(?&lt;=\.)\D\D(?:-\D{2,3}?(?:-\D\D\D\D)?)?(?=.resx) #Just change the extension if you want to take a Culture out of different type of file name. #The result will always be of the format: #(2CharacterLanguage)-(2or3CharacterLocale)-(4CharacterScript) #where the second or third set are optional #this matches the format of the CultureInfo object in Microsoft .NET
Description
This expression pulls the Culture name out of a .resx file name.
Matches
blah.is.en.resx | something.zh-CHS.resx | something.uz-UZ-Cyrl.resx
Non-Matches
blah.is.eee.resx | something.zh-X.resx | something.uz-UZ-Uz.resx
Author Rating: Not yet rated. Eric Falsken
Title Test Details Check filename extensions
Expression
^.*(([^\.][\.][wW][mM][aA])|([^\.][\.][mM][pP][3]))$
Description
Matches a file name to be either a .wma or .mp3 file. This can be used to check file uploads to make sure they are of a certain type. Substitute letters where appropriate for specific file types. This is a better solution (I think) than #343. Works in Javascript and C#.
Matches
thisfile.mp3 | [email protected]
Non-Matches
whatever.exe | somethingelse.mpa | thisagain.wm3 | filenamemp3 | filename..mp3 | filename.wmap3
Author Rating: Not yet rated. Dusan Hlavaty
Title Test Details HTML server side include tag
Expression
<!--\s*\#\s*include\s+(file|virtual)\s*=\s*(["'])([^"'<>\|\b]+/)*([^"'<>/\|\b]+)\2\s*-->
Description
Works with virtual or file include type and double or single quotes. Breaks out include type, include file path, and include file name.
Matches
<!--#include file="include/js/common.js"--> <!-- # include virtual = 'test header.inc' -->
Non-Matches
<!--#include file='header.inc"-->
Author Rating: Not yet rated. Jeremy Backus
Title Test Details Newzbin File Name Prefix Stripper
Expression
(?<=\d{7}_).+((?=\x5B\d\x5D)|.{3})
Description
Although written specifically to strip Newzbin version 2 and 3 prefixes and the [1] IE adds in Newsbin from NZB file names, this expression can be modified to search for any prefix/suffix combination. It also provides an example of using of grouping constructs to remove matching text.
Matches
msgid_0000000_Any_Text[1] | 0000000_Any_Text
Non-Matches
msgid 0000000 | messageid | 000000
Author Rating: Not yet rated. Jim Fritz
Title Test Details Last word
Expression
\w*$
Description
Finds the last word in a string eg. the user in \\domain\user or the extension/file type in a file name.
Matches
\\domain\user
Non-Matches
I want lots of $$
Author Rating: Not yet rated. Thomas Nielsen
Title Test Details Last word
Expression
\w*$
Description
Finds the last word in a string eg. the user in \\domain\user or the extension/file type in a file name.
Matches
\\domain\user
Non-Matches
I wan't lots of $$
Author Rating: Not yet rated. Thomas Nielsen
Title Test Details Select File Accept Arabic and Englesh File name or Folder name
Expression
^[a-zA-Z]:\\(([\w]|[\u0621-\u064A\s])+\\)+([\w]|[\u0621-\u064A\s])+(.jpg|.JPG|.gif|.GIF|.BNG|.bng)$
Description
Select File Accept Arabic and Englesh File name or Folder name
Matches
C:\Documents and Settings\mohamedantar\ملف\My Pictures\صورة.gif
Non-Matches
:\Documents and Settings\mohamedantar\ملف\My Pictures\صورة.gif
Author Rating: Not yet rated. Mohamed Antar Ibrahem
Title Test Details Parse file path
Expression
^(?<1>.*[\\/])(?<2>.+)\.(?<3>.+)?$|^(?<1>.*[\\/])(?<2>.+)$|^(?<2>.+)\.(?<3>.+)?$|^(?<2>.+)$
Description
Parses any file path and extracts directory, file name and extension separately.
Matches
d:\Program Files\Hello.txt | /home/Hello.txt | Hello.txt | .\Hello
Non-Matches
\\Hello\ | Hello\\
Author Rating: Not yet rated. Tim
Title Test Details Pattern Title
Expression
^(?:(?<scheme>[a-z]+):\/\/)?(?:(?<usern>[a-z0-9_.]*)(?::(?<passw>[a-z0-9_.]*))[email protected])?(?<domain>(?:(?:[a-z][a-z0-9_-]+\.?)+|[0-9]{1,3}(?:\.[0-9]{1,3}){3}))(?::(?<port>[0-9]+))?(?<path>(?:\/[.%a-z0-9_]*)+)?(?:\?(?<query>(?:&?[][a-z0-9_]+(?:\=?[a-z0-9_;]*)?)+))?(?:#(?<fragment>[a-z0-9_]+))?$
Description
Matches URI's! "filename.ext" is part of path. ER can't differ file name from directory name. only domain is required. scheme://usern:[email protected]:port/path/file.ext?querystring#fragment
Matches
domain | ftp://localhost:21/ | 192.168.254.0 | http://username:[email protected]:1234/path1/pathX/filename.ext?query=string&example=v1#fragment
Non-Matches
non-alpha://domain | domain:non-number
Author Rating: The rating for this expression. Wesley Menezes
Title Test Details Validate MS DOS 8.3 Directory or File name (without extension)
Expression
[^ _0-9a-zA-Z\$\%\'\-\@\{\}\~\!\#\(\)\&\^]
Description
Use this regular expression to find any invalid characters within a DOS 8.3 Directory or Folder name. Reference: http://support.microsoft.com/?id=120138
Matches
one$two folder_name [email protected]
Non-Matches
one:two folder*name file:name
Author Rating: The rating for this expression. Charles Forsyth
Title Test Details Windows Filename
Expression
^[^ \\/:*?""<>|]+([ ]+[^ \\/:*?""<>|]+)*$
Description
This was written for C# and so you should just be able to drop it into your C# program. Although you can create files with leading and trailing spaces through non-GUI means, the Windows GUI itself eats those spaces if you try to rename the file. For this reason I made the decision to consider file names with leading and trailing spaces invalid. This has been tested against large data sets.
Matches
bla, file.txt, [email protected]#$
Non-Matches
bla , file:txt, /\*?
Author Rating: Not yet rated. Tristan DF Wilson
Title Test Details File Name
Expression
^([a-zA-Z]:\\)?[^\x00-\x1F"<>\|:\*\?/]+\.[a-zA-Z]{3,4}$
Description
This matches a valid windows filename. Not a valid path.I wanted something simple that covered all the bases
Matches
file.txt | fie.txt.pdf | file(with parenthesis).pdf
Non-Matches
*file.pdf | file.tx
Author Rating: The rating for this expression. Jose Paulino
Title Test Details URL File Name
Expression
(?<!/)/(\w+\.\w+)?$
Description
Gets the file name from a URL including the "/". If the URL ends in "/" the "/" is matched.
Matches
/index.htm | / | /default.aspx
Non-Matches
google.com | hi everybody | \myFile.txt
Author Rating: The rating for this expression. Brendan Enrick
Title Test Details Parse Windows Filename / Pathname (simple version)
Expression
/(?:(.):)?(?:(.*)\\)?(?:(.*)\.)?(.*)/
Description
Does not validate. For parsing a file name known to be valid. Handles periods in the file name. Does not include terminating characters in the output, as preferred. Javascript exec() method produces the following array elements: [1]=drive; [2]=path; IF extension exists THEN [3]=filename; [4]=extension; ELSE [3]=undefined; [4]=filename. (To avoid the awkwardness, see "Parse Windows Filename (complex version)." Matching Example 1 output: [1]=d [2]=\p.p\p [3]=f.f [4]=e Matching Example 2 output: [1]=[undefined] [2]=[empty string] [3]=[undefined] [4]=f Matching Example 3 output: [1]=undefined [2]=undefined [3]=f [4]=e
Matches
'd:\\p.p\\p\\f.f.e' | '\\f' | 'f.e'
Non-Matches
matches all
Author Rating: Not yet rated. Brian \S\s
Change page:   |    Displaying page 1 of 2 pages; Items 1 to 20

Copyright © 2001-2021, RegexAdvice.com | ASP.NET Tutorials