Tags » Regex

Regex as properties

There have been multiple situations when I have had to store “patterns” externally only to load them later and compare them against existing values. For Eg. 344 more words


mongodb exception: can't convert from BSON type String to Date

Problem: When attempting to do an aggregation on timestamps which are stored as strings, mongodb is unable to do the conversion

repmongo:SECONDARY> db.collection.aggregate(
…     { $match : { "type" : "Review"}}, …

290 more words


Hey everyone! We’re switching things up a bit today and writing this post in English*! This week in class we went over some basic regular expressions and how they can help us in our project so we’re going to take a quick break from talking about urls, html, and same-sex marriage to share some of our regex knowledge with you guys. 943 more words

regex, append a find with string

I am trying to add sheet names to cells in an excel formula that do not have sheet names.
For example a formula on curr_sheet : 103 more words

Recent Questions - Stack Overflow

The regex of txtsh

I know I shouldn’t, but I can’t help but write my own version of everything I need for txtsh. I think of it as a learning experience. 532 more words


Regex, one occurrence between two differents delimiters

I’d like to have a regex which select everything between the not-included characters delimiters “`” and “I”. I only want the first occurrence.

Here is my wrong try (very new to regex) : “(^`)\s\S?” 12 more words

Recent Questions - Stack Overflow

Java regex match single line

public class TestJavaRegexMatchingSingleLine {

    private static final String WINDOWS_LINES = "first line\r\nsecond line \r\n third line";
    private static final String UNIX_LINES = "first line\rsecond line \r third line";

    public void shouldNotFindMatching() throws Exception {
        assertFalse(Pattern.compile("^.*$").matcher(UNIX_LINES).find()); // dot '.' by default does not match \r not \r\n; anchors ^ and $ indicate begin and end of input string

    public void shouldFindWindowsLines() throws Exception {

    public void shouldFindUnixLines() throws Exception {

    private void shouldFindLinesUsingMultiLineMode(String multiLineText) {
        Matcher m = Pattern.compile("(?m)^.*$").matcher(multiLineText); // (?m) MULTI-LINE mode - when explicitly enabled - makes anchors ^ and $ indicate begin and end of line
        List<String> lines = new ArrayList<String>();
        while (m.find()) {
            System.out.println("line = '" + m.group() + "'");
        assertEquals(3, lines.size());
        assertEquals("first line", lines.get(0));
        assertEquals("second line ", lines.get(1));
        assertEquals(" third line", lines.get(2));