Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID


We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Regular expression help

jaymajors1234jaymajors1234 Posts: 3Member
I have the following regular expression who's intention is to strip the first match on this string and everything else on the line.

matchingText ="


  • infidelinfidel Posts: 2,900Member
    : I have the following regular expression who's intention is to strip the first match on this string and everything else on the line.
    : matchingText ="
  • jaymajors1234jaymajors1234 Posts: 3Member
    Sorry for the ugly format on the code, the paste doesnt take very well. What I am trying to do is modify a script that was generated by a program called Grinder which is being used to generate load on a web server.

    Most of the code here is creating a request object. The regular expression code is inside the def __call__self function. When I run it I get the following error message...

    9/28/05 11:51:14 AM (thread 0 run 0): Aborted run, script threw class org.python.core.PyException: null
    Traceback (innermost last):
    File "", line 142, in __call__
    File "", line 57, in search
    File "", line 134, in _compile
    File "", line 368, in compile
    File "", line 352, in _code
    File "", line 61, in _compile
    File "", line 141, in _compile
    ValueError: ('unsupported operand type', 'any')

    at org.python.core.Py.makeException(
    at sre_compile$py._compile$1(
    at sre_compile$py.call_function(
    at org.python.core.PyFunction.__call__(
    at sre_compile$py._compile$1(
    at sre_compile$py.call_function(
    at org.python.core.PyFunction.__call__(
    at sre_compile$py._code$9(
    at sre_compile$py.call_function(
    at org.python.core.PyFunction.__call__(
    at sre_compile$py.compile$10(
    at sre_compile$py.call_function(
    at org.python.core.PyFunction.__call__(
    at org.python.core.PyObject.invoke(
    at sre$py._compile$12(
    at sre$py.call_function(
    at org.python.core.PyFunction.__call__(
    at sre$$2(
    at sre$py.call_function(
    at org.python.core.PyFunction.__call__(
    at org.python.core.PyObject.invoke(
    at org.python.pycode._pyx0.__call__$2(
    at org.python.pycode._pyx0.call_function(
    at org.python.core.PyFunction.__call__(
    at org.python.core.PyMethod.__call__(
    at org.python.core.PyObject.invoke(
    at org.python.core.PyInstance.__call__(
    at org.python.core.PyObject.__call__(
    at net.grinder.engine.process.JythonScript$
    at Source)

    Here is the code:

    import re
    from random import *
    from string import *

    from customeradd_tests import *
    from net.grinder.script.Grinder import grinder
    from net.grinder.plugin.http import HTTPRequest

    responseText = ""

    class TestRunner:

    def __call__(self):

    ( NVPair('userId', 'weblogic'),
    NVPair('password', 'weblogic'), ))

    ( NVPair('nextView', 'IndividualCustomerAdd'),
    NVPair('disableStaging', 'true'),
    NVPair('require_check', 'false'), ))

    result = tests[2].POST('http://localhost:10000/spectrum/sc/',
    ( NVPair('view_name', 'IndividualCustomerAdd'),
    NVPair('activeSection', 'Individual Customer Add'),
    NVPair('activeCategory', 'General'),
    NVPair('lastRetrieveEventBaseDomainObjectId', ''),
    NVPair('event.customer.honorific', ''),
    NVPair('event.customer.firstName', 'Test'),
    NVPair('event.customer.middleName', ''),
    NVPair('event.customer.lastName', 'User'),
    NVPair('event.customer.generationType', ''),
    NVPair('event.customer.birthDate', '10/29/1978'),
    NVPair('event.customer.maritalStatus', ''),
    NVPair('event.customer.occupation', ''),
    NVPair('event.customer.alias', ''),
    NVPair('event.customer.reportingName', ''),
    NVPair('event.customer.motherMaidenName', ''),
    NVPair('event.customer.languagePreference', ''),
    NVPair('event.customer.citizenshipStatus', ''),
    NVPair('event.customer.FRBCode', ''),
    NVPair('event.customer.legalType', 'INDIVIDL'),
    NVPair('event', 'customerAdd'),
    NVPair('visibleSection', 'Summary'),
    NVPair('customerListIndex', ''),
    NVPair('event.inputSetName', ''),
    NVPair('event.inputSetSource', ''),
    NVPair('event.processDate', '10/29/2004'),
    NVPair('event.stagingTransaction.isPostable', ''),
    NVPair('event.stagingTransaction.savedAsName', ''),
    NVPair('event.stagingTransaction.transactionSource', 'WEB'),
    NVPair('event.customer.number', str(randrange(0, 999999999))),
    NVPair('event.customer.legalReportingType', 'SSN'),
    NVPair('event.customer.SSN', str(randrange(100000000, 999999999))),
    NVPair('event.customer.taxIdentifier', ''),
    NVPair('event.customer.salesTaxExemptionCode', 'NONEXEMPT'),
    NVPair('event.customer.CIFCISID', ''),
    NVPair('event.customer.nextAddress(PRIMARY).isPrimaryAddress', 'true'),
    NVPair('event.customer.nextAddress(PRIMARY).isActive', 'true'),
    NVPair('event.customer.nextAddress(PRIMARY).streetNumber', '123'),
    NVPair('event.customer.nextAddress(PRIMARY).streetName', '123'),
    NVPair('event.customer.nextAddress(PRIMARY).thoroughfareType', ''),
    NVPair('event.customer.nextAddress(PRIMARY).streetDirection', ''),
    NVPair('event.customer.nextAddress(PRIMARY).unitNumber', ''),
    NVPair('event.customer.nextAddress(PRIMARY).postOfficeBox', ''),
    NVPair('event.customer.nextAddress(PRIMARY).mailStation', ''),
    NVPair('event.customer.nextAddress(PRIMARY).streetAddressLine1', ''),
    NVPair('event.customer.nextAddress(PRIMARY).streetAddressLine2', ''),
    NVPair('event.customer.nextAddress(PRIMARY).urbanizationCode', ''),
    NVPair('event.customer.nextAddress(PRIMARY).city', '123'),
    NVPair('event.customer.nextAddress(PRIMARY).state', 'VA'),
    NVPair('event.customer.nextAddress(PRIMARY).postalCode', '12312-'),
    NVPair('event.customer.nextAddress(PRIMARY).county', ''),
    NVPair('event.customer.nextAddress(PRIMARY).country', 'US'),
    NVPair('event.customer.nextAddress(PRIMARY).establishedDate', ''),
    NVPair('event.customer.nextAddress(PRIMARY).censusTract', ''),
    NVPair('event.customer.nextAddress(PRIMARY).msa', ''),
    NVPair('event.customer.nextAddress(PRIMARY).geoCode', ''),
    NVPair('event.customer.nextEmployment.address.addressType', 'EMPLOYER'),
    NVPair('event.customer.nextEmployment.address.isPrimaryAddress', ''),
    NVPair('event.customer.nextEmployment.address.isActive', ''),
    NVPair('event.customer.nextEmployment.employerName', ''),
    NVPair('event.customer.nextEmployment.employeeCode', ''),
    NVPair('event.customer.nextEmployment.employmentDate', ''),
    NVPair('event.customer.nextEmployment.employmentTitle', ''),
    NVPair('event.customer.nextEmployment.employmentStatus', 'FULLTIME'),
    NVPair('event.customer.nextEmployment.department', ''),
    NVPair('event.customer.nextEmployment.address.streetNumber', ''),
    NVPair('event.customer.nextEmployment.address.streetName', ''),
    NVPair('event.customer.nextEmployment.address.thoroughfareType', ''),
    NVPair('event.customer.nextEmployment.address.streetDirection', ''),
    NVPair('event.customer.nextEmployment.address.unitNumber', ''),
    NVPair('event.customer.nextEmployment.address.postOfficeBox', ''),
    NVPair('event.customer.nextEmployment.address.mailStation', ''),
    NVPair('event.customer.nextEmployment.address.streetAddressLine1', ''),
    NVPair('event.customer.nextEmployment.address.streetAddressLine2', ''),
    NVPair('event.customer.nextEmployment.address.urbanizationCode', ''),
    NVPair('', ''),
    NVPair('event.customer.nextEmployment.address.state', ''),
    NVPair('event.customer.nextEmployment.address.postalCode', ''),
    NVPair('event.customer.nextEmployment.address.county', ''),
    NVPair('', 'US'),
    NVPair('event.customer.nextEmailAddress.emailType', ''),
    NVPair('event.customer.nextEmailAddress.emailAddress', ''),
    NVPair('event.customer.nextPhoneNumber.phoneType', 'CELLPHONE'),
    NVPair('event.customer.nextPhoneNumber.phoneNumberRelationshipList', ''),
    NVPair('event.customer.nextPhoneNumber.phoneNumberWithAreaCode', ''),
    NVPair('event.customer.nextPhoneNumber.extension', ''),
    NVPair('event.customer.nextPhoneNumber.inService', 'true'),
    NVPair('event.customer.nextPhoneNumber.countryCode', '1'),
    NVPair('event.customer.nextFinancialAccount.accountType', ''),
    NVPair('event.customer.nextFinancialAccount.financialInstitutionName', ''),
    NVPair('event.customer.nextFinancialAccount.accountNumber', ''),
    NVPair('event.customer.nextFinancialAccount.abaRoutingNumber', ''),
    NVPair('event.customer.nextFinancialAccount.institutionType', ''),
    NVPair('event.customer.nextFinancialAccount.securityCode', ''),
    NVPair('event.customer.nextFinancialAccount.isEligibleForPaymentDraft', ''),
    NVPair('event.customer.nextFinancialAccount.accountDescription', ''),
    NVPair('event.customer.nextIdentification.identificationType', ''),
    NVPair('event.customer.nextIdentification.identificationNumber', ''),
    NVPair('event.customer.nextIdentification.applicationDate', ''),
    NVPair('event.customer.nextIdentification.issueDate', ''),
    NVPair('event.customer.nextIdentification.identificationState', ''),
    NVPair('', 'US'),
    NVPair('event.customer.nextIdentification.issuingAuthority', ''),
    NVPair('event.customer.nextIdentification.expirationDate', ''),
    NVPair('event.customer.nextIdentification.IDVerifiedByName', ''),
    NVPair('event.customer.nextIdentification.IDVerifiedByDate', ''), ))


    matchingText ="
  • infidelinfidel Posts: 2,900Member
    : The matchingText line is indented inside of the __call__(self) method.

    This message board has some stylecodes you can use to keep indentation, just surround your code with [leftbr]code[rightbr] and [leftbr]/code[rightbr], kind of like HTML tags.

    : Again thanks for your help. Hope this gives you enough to tell me what im doing wrong. The interesting thing about this is, I wrote the value from result.getText() into a file, and wrote another program that read in the file and ran this regular expression against it and everything worked. Without the errors above, thats why I thought it may have something to do with the class def. When i remove these lines from the program the program runs as expected, which basically posts a customer to my database.

    I don't have jython set up, so it's possible that there's something there causing your problem, but I doubt it. The error is definitely coming from the sre module (which is what re uses behind the scenes).

    A few things I notice that seem odd to me. The x being passed to isn't set to any value anywhere that I can see, and result.getText() isn't assigned to anything, so I'm guessing you meant:

    x = result.getText()

    Or something like that.

    It also looks like the tuples you're passing to the GET and POST methods of your test objects contain an extra comma at the end:

    ( NVPair('userId', 'weblogic'),
    NVPair('password', 'weblogic')[red],[/red] ))

    I'm surprised that isn't raising a syntax error, though perhaps jython allows it?

    I just found these messages:

    Maybe this is the problem?


    $ select * from users where clue > 0
    no rows returned

  • jaymajors1234jaymajors1234 Posts: 3Member
    [b][red]This message was edited by jaymajors1234 at 2005-9-29 6:31:38[/red][/b][hr]
    Thanks for the heads up on the codes block, I will be sure to use those in the future.

    Your correct about the result.text() not being assigned, I reverted the code before I sent that post so I typed some of the lines at the end and missed that.

    The threading issue that post you pointed me to was my problem, once I moved the re.compile statement out of the test things worked as planned. However while I was banging my head against the monitor I found another solution to the problem.

    I used a combination of the String find method and the [:] functionality to find the string that way.

    As for those name value pairs, they are spit out by the tcp proxy that comes with the grinder framework. They do look bad but i would rather not change them

Sign In or Register to comment.