خرید بک لینک

Vote count: 0

I am streaming plain text records via MapReduce and need to check each plain text record for 2 or more consecutive punctuation symbols. The 12 symbols I need to check for are: -/()!"+,'&.

I have tried translating this punctuation list into an array like this: punctuation = [r'-', r'/', r'', r'(', r')', r'!', r'"', r'+', r',', r"'", r'&', r'.']

I can find individual characters with nested for loops, for example:

for t in test_cases:
    print t
    for p in punctuation:
        print p
        if re.search(p, t):
            print 'found a match!', p, t
        else:
            print 'no match'

However, the single backslash character is not found when I test this and I don't know how to get only results that are 2 or more consecutive occurrences in a row. I've read that I need to use the + symbol, but don't know the correct syntax to use this.

Here are some test cases:

The quick '''brown fox
The &&quick brown fox
The quickbrown fox
The quick\brown fox
The -quick brown// fox
The quick--brown fox
The (quick brown) fox,,,
The quick ++brown fox
The "quick brown" fox
The quick/brown fox
The quick&brown fox
The ""quick"" brown fox
The quick,, brown fox
The quick brown fox…
The quick-brown fox
The ((quick brown fox
The quick brown)) fox
The quick brown fox!!!
The 'quick' brown fox

Which when translated into a Pythonic list looks like this:

test_cases = [
"The quick '''brown fox",
'The &&quick brown fox',
'The quick\brown fox',
'The quick\\brown fox',
'The -quick brown// fox',
'The quick--brown fox',
'The (quick brown) fox,,,',
'The quick ++brown fox',
'The "quick brown" fox',
'The quick/brown fox',
'The quick&brown fox',
'The ""quick"" brown fox',
'The quick,, brown fox',
'The quick brown fox...',
'The quick-brown fox',
'The ((quick brown fox',
'The quick brown)) fox',
'The quick brown fox!!!',
"The 'quick' brown fox" ]

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 3 ارديبهشت 1395 ساعت: 2:06

صفحه بندی