Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Capturing a strings value in a regular expressions

  • 13-11-2015 08:45AM
    #1
    Registered Users, Registered Users 2 Posts: 262 ✭✭


    Im analysing some output from a command in python

    The output as follows

    5 instance(s) updated

    I want to extract the number before the rest of the string for later calculations and assign to a variable amount_of_instances but i don't know how to

    Current code

    commands[config.get_prop("app_get_all_attribute_values_for_mo").format(managed_object="Object1", attribute="Object2", value=Object3)] = {'contains': [" instance(s)"], 'cache_response': [{"amount_of_instances": r"\d+ instance(s)"}]}


Comments

Advertisement