Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with match and replace #962

Closed
johnnyzen opened this issue Aug 8, 2015 · 6 comments
Closed

Help with match and replace #962

johnnyzen opened this issue Aug 8, 2015 · 6 comments

Comments

@johnnyzen
Copy link

Hi all

I am trying to match and replace various events from different sources using just one formatting agent - which I use the url to determine the source.

{
  "instructions": {
    "source": "{{formatted_source}}"
  },
  "matchers": [
    {
      "path": "{{link}}",
      "regexp": "regex_replace: 'W*((?i)bbc(?-i))W*', 'BBC News'",
      "to": "formatted_source"
    },
    {
      "path": "{{link}}",
      "regexp": "regex_replace: 'W*((?i)telegraph(?-i))W*', 'Telegraph News'",
      "to": "formatted_source"
    }
  ],
  "mode": "merge",
  "skip_agent": true,
  "skip_created_at": true
}

I am not sure if I can use regex_replace within the regexp?

Not getting any results, and wondered if someone could assist me

Many thanks

@schulzpin
Copy link

I'm also interested in some kind of tutorial about using regex_replace function. In what agent should I use it? Is there a way to cut a piece of text/code from the incoming feed?
It would be great if someone could make detailed wiki page with few examples.

@cantino
Copy link
Member

cantino commented Aug 8, 2015

regex_replace is a Liquid filter and I don't think it can currently be used inside of the regex key in an EventFormattingAgent.

I don't think the matchers groups of an EventFormattingAgent can currently do replacement.

As an aside, @knu, is path here confusingly named? It looks like it's the actual data to match, not the JSONPath to that data.

@johnnyzen
Copy link
Author

Would I be able to pay someone to get this done or is there another way ?

Where can regex_replace be used ? maybe I can do in the website agent?

@johnnyzen
Copy link
Author

Decided to handle this regex client side, as cant find a solution at the moment.

Thanks all for help and loving huginn. Thanks for the great software :)

@cantino
Copy link
Member

cantino commented Aug 28, 2015

What do you think a regex replace should look like? We could add it as a new feature of the EventFormattingAgent.

@cantino
Copy link
Member

cantino commented Feb 14, 2016

Closing since we haven't heard back. Hope it's working for you!

@cantino cantino closed this as completed Feb 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants