Search code examples
regexyahoo-pipes

Regex remove last dot from string in Yahoo Pipes


I have a couple of strings that end with a dot (.) at the end of the sentence which I need to remove in Yahoo Pipes.

Example:

example.com.
companywebsite.co.uk.
anothersite.co.

I've tried the following from a couple of posts here on SO but none have worked yet

/\.$/

or

^(.*)\\.(.*)$","$1!$2

Neither of these options have worked

I have tried a very simple find of

 .com. and replace with .com

and

 .co. to replace with .co

But the latter affects .com as well which is not ideal

EDIT: Here is a visual of what my pipe looks like.

enter image description here


Solution

  • If you can do something like this: ^(.*)\\.(.*)$","$1!$2, then doing this should work: "^(.+?)\.?$", $1. This should match the first part of the URL and leave out the period at the end, should it exist.

    EDIT:

    As per your image, you should place this: ^(.+?)\.?$ in your replace field and this: $1 in your with field. I do not know if you need to do any escaping, so you might have to use ^(.+?)\\.?$ instead of ^(.+?)\.?$.

    enter image description here