matching parentheses in python regular expression


I have something like




ending line like 1 store(s) .. I want to match , it using python regular expression.

I tried something like re.match('store\(s\)$',text) but it's not working .

EDIT : adding the code , I tried

import re s = '1 store(s)' if re.match('store\(s\)$',s) : print('match')

Pls help.

Thanks Jijoy


In more or less direct reply to your comment


Try this

import re s = '1 stores(s)' if re.match('store\(s\)$',s): print('match') </blockquote>

The solution is to use re.search instead of re.match as the latter tries to match the whole string with the regexp while the former just tries to find a substring inside of the string that does match the expression.



Python offers two different primitive operations based on regular expressions: <strong>match</strong> checks for a match <strong>only at the beginning</strong> of the string, while <strong>search</strong> checks for a match <strong>anywhere</strong> in the string (this is what Perl does by default)


Straight <a href="http://docs.python.org/library/re.html#matching-vs-searching" rel="nofollow">from the docs</a>, but it does come up alot.


have you considered re.match('(.*)store\(s\)$',text) ?


  • String to date conversion android
  • angular2 material “progress circle”
  • How to convert 32-bit binary to float
  • How can we find device token in android emulator for Google Cloud Messaging
  • How to filter a range by first Character in a cell?
  • Using DOM parser in Android
  • PL/SQL on SquirreL SQL Client 3.7.1
  • PHP - sending email with attachment does not show message content
  • PHP mail() function not delivering mail
  • How to reply a tweet using the Twitter gem?
  • get latest text entry of GROUP BY statement
  • Representing intervals or ranges? [closed]
  • How to get to older Xcode beta version?
  • how to convert open xml representation of word document into RTF format using c#.net 4.0?
  • What does the TypeScript “lib” option really do?
  • Vigenere cipher not working
  • How to resolve permission denied maybe missing internet permission?
  • How can we prepend rows to a react native list-view?
  • Can I use AllJoyn Framework for Wifi Direct in iOS?
  • PLSQL: Get number of records updated vs inserted when a merge statement is used
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • How Lists (specifically, RecyclerView with CardViews) in Android work
  • Code in Job's Script Block after Start-Process Does not Execute
  • Custom Tabgroup Appcelerator
  • $wpdb not working in file of WordPress plugin
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Matplotlib draw Spline from multiple points
  • Why winpcap requires both .lib and .dll to run?
  • align graphs with different xlab
  • Return words with double consecutive letters
  • Arrays break string types in Julia
  • Python: how to group similar lists together in a list of lists?
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How can I remove ASP.NET Designer.cs files?
  • Busy indicator not showing up in wpf window [duplicate]
  • Reading document lines to the user (python)
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal