# Newb wondering what I've screwed up with my Python RegEx

**URL:** <https://forum.ansible.com/t/newb-wondering-what-ive-screwed-up-with-my-python-regex/13920>\
**Category:** Ansible Project\
**Created:** [November 17, 2013, 5:17am UTC](https://forum.ansible.com/t/newb-wondering-what-ive-screwed-up-with-my-python-regex/13920 "2013-11-17T05:17:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Haddox](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steven\_Haddox](https://forum.ansible.com/u/Steven_Haddox)\
**Post date:** [November 17, 2013, 5:17am UTC](https://forum.ansible.com/t/newb-wondering-what-ive-screwed-up-with-my-python-regex/13920/1 "2013-11-17T05:17:01Z")

</div>

I’m a Rubyist by day (with three years of Python once upon a time) and I’m struggling with getting the following task to only run once with the regular expression below. According to Pythex it should be matching (see: [http://bit.ly/1dGw2GV](http://bit.ly/1dGw2GV)).

My task looks as follows and should add the following line to ~/.bashrc if it doesn’t already exist:

export PATH=${STOW}/…/bin:${PATH}

- name: Ensure $STOW is in $PATH  
lineinfile:  
dest={{HOME.stdout}}/.bashrc  
regexp=“^export PATH=${STOW}.\*”  
line=“export PATH=${STOW}/…/bin:${PATH}”  
state=present  
insertafter=EOF  
create=True

With this version of it the line is added properly, with each and every run instead of just the initial run even though I get a full match on pythex…

I’m wondering if I should be testing against a different regular expression parser (I realize there are slight variations between languages) or if I’m just missing something blatantly obvious?

Any help appreciated,

Steven

PS - “${STOW}” in the above is a previously exported environment variable, not an attempt to insert an ansible variable of some kind.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 17, 2013, 5:56pm UTC](https://forum.ansible.com/t/newb-wondering-what-ive-screwed-up-with-my-python-regex/13920/2 "2013-11-17T17:56:22Z")

</div>

This may be useful:

[http://www.pythonregex.com/](http://www.pythonregex.com/)
