The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for the ‘RegEx’ Category

grep: searching for pipes, optional characters

Posted by jpluimers on 2016/09/22

For my own reference as RegEx is a write-only language:

Search for pipes means just back-slash escaping them:

grep "\|S\|" products.txt > s-rated-products.txt

Search for optional charactes (in this case searching for both the singular and plural form of a word) can be done by grouping the optional part in parentheses:

grep -i "Movie(s)?" products.txt > movie-products.txt

Search for either OR:

grep -E "foo|bar" products.txt > foo-or-bar-products.txt
egrep "foo|bar" products.txt > foo-or-bar-products.txt

Note that the Borland grep does not support the OR syntax, but egrep does.

–jeroen

via:

Posted in Development, RegEx, Software Development | Leave a Comment »

findstr as alternative for recursive grep search

Posted by jpluimers on 2016/04/27

Usually I use the old Borland grep.exe that still ships with Delphi. Too bad it is 16-bit app which does not recognise Unicode.

FindStr does. Though much slower and with limited regular expression capabilities, can do recursive searches too:

findstr /spin /c:"string to find" *.*

The /spin is a shortcut for these case insensitive command-line options (the full list of possible options is below):

  /S         Searches for matching files in the current directory and all
             subdirectories.
  /I         Specifies that the search is not to be case-sensitive.
  /N         Prints the line number before each line that matches.
  /P         Skip files with non-printable characters.

Sometimes I leave out the /P to include binary files.

–jeroen

via:

Read the rest of this entry »

Posted in Batch-Files, Development, Power User, RegEx, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows 8.1, Windows NT, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Vista, Windows XP | Leave a Comment »

.NET Regex Tester – Regex Storm

Posted by jpluimers on 2016/01/26

Greate stuff:

Online .NET regular expression tester with real-time highlighting and detailed results output.

Allowed me to quickly verify the pattern PWWWC\d\dFE\d\d_\d\d\d\d-\d\d-\d\d\.zip matches only one of these filenames:

PWWWC07RI01_2016-01-10.zip
PWWWC08FE03_2016-01-04.zip
PAPPC00BT01_2016-01-04.zip

–jeroen

Source: .NET Regex Tester – Regex Storm

Posted in .NET, Development, RegEx, Software Development | Leave a Comment »

7 Linux Grep OR, Grep AND, Grep NOT Operator Examples

Posted by jpluimers on 2015/10/31

Question: Can you explain how to use OR, AND and NOT operators in Unix grep command with some examples?

Source: 7 Linux Grep OR, Grep AND, Grep NOT Operator Examples

Posted in *nix, *nix-tools, Power User, RegEx | Leave a Comment »

Repeating the same expression multiple in RegEx search, and replace it only one time – via: Stack Overflow

Posted by jpluimers on 2015/07/29

I’m really really glad that Lucas Trzesniewski has answered this:

While most regex flavours have roughly a similar syntax for the basic features, there is not a clear standard as to the syntax of the replacement strings. Some tools use \1 for referencing strings, others use $1 and so on.

As you use Notepad++, you should know it uses the boost library for its regex implementation, and it uses the Boost-Extended format string for the replacement pattern.

In particular, the placeholder for the nth capture group is $n.

And my comment:

Thanks a lot for that. I found a bit more information about back references and capture groups in various libraries on regular-expressions.info/replacebackref.html.

on my question: Read the rest of this entry »

Posted in Development, RegEx, Software Development | Leave a Comment »

XSD regular expressions are a tad different: creating GroupProj.xsd

Posted by jpluimers on 2014/12/31

While creating jeroenp / BeSharp.net / source / Native / Delphi / Scripts / GroupProj.xsd — Bitbucket, I bumped into the fact that regular expressions in XSD *or better XML Schema Regular Expressions) regular expressions are a tad different than the RegEx.

Actually, there are quite a few regular expression flavours, and all of them are a tad different. The page Compare Regular Expression Flavors at Regular-Expressions.info.

That is a great site with Regex Tutorial, Examples and Reference – Regexp Patterns by RegEx guru Jan Goyvaerts (yes, that looks Dutch, but he was born in Belgium and now lives in Phuket) famous for tools like PowerGREP and RegExBuddy. All based on the great Delphi RegEx PCRE library written by Jan and included in Delphi XE and up.

The thing that baffled me most is that even though XML Schema Regular Expressions do not support anchors ^ and $, you still have to escape them.

–jeroen

via: XML Schema Regular Expressions.

Posted in Development, RegEx, Software Development, XML/XSD, XSD | 2 Comments »

Tools to generate sample data from regeX expressions (via: Stack Overflow)

Posted by jpluimers on 2014/12/30

Thanks DD59 for posting these interesting links:

I like the name `Xeger`.

–jeroen

via: xml – Generate a valid example value for a xs:pattern – Stack Overflow.

Posted in .NET, Development, Java, RegEx, Software Development, Visual Studio and tools | Leave a Comment »

Jeffrey’s Exif viewer: a great non-regex thing on regex.info (:

Posted by jpluimers on 2013/09/19

You’d think that the regex.info site only has information on Jeffrey Friedl’s Mastering Regular Expressions (a great book on RegEx programming) MRE2 Errata,  MRE3 Errata and Where to get egrep (agrep and sourcecode/binary builds).

Not so (:

It also hosts a few other things, mostly having to do with imagery or photography:

–jeroen

Posted in Development, Personal, Photography, Power User, RegEx, Software Development | Leave a Comment »

Time for a golden oldie: Pragmatic Software Development Tips

Posted by jpluimers on 2013/05/09

From the century start era of The Pragmatic Bookshelf | The Pragmatic Programmer, a – still valid – list of Pragmatic Software Development Tips.

From Care About Your Craft, via DRY, Some Things Are Better Done than DescribedKeep Knowledge in Plain Text, Work With a User to Think Like a User, Find the Box, and many others till Sign Your Work.

–jeroen

via: The Pragmatic Bookshelf | List of Tips.

Posted in .NET, C++, Cloud Development, COBOL, CommandLine, Delphi, Development, Fortran, iSeries, Java, Pascal, RegEx, Scripting, Software Development, Web Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 3 Comments »

xkcd: Perl Problems; I got 99 problems. So I used regular expressions.

Posted by jpluimers on 2013/02/08

(:

I got 99 problems. So I used regular expressions...
I got 99 problems. So I used regular expressions…

–jeroen

via: xkcd: Perl Problems.

Posted in Development, Perl, RegEx, Scripting, Software Development | Tagged: , , | Leave a Comment »