Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Regex to retrieve part of string

  1. #1

    Default Regex to retrieve part of string

    Hi all,


    I want to retrieve 25 from following string.
    For example: Sunday, 25 March, 01:00
    The format of above string is fixed.
    Can I get it by using regex?
    Please can anybody help me in creating regex for this?
    I am trying to use "replace string" step for this.
    Please let me know if any other easy way for implementation


    Thanks

  2. #2
    Join Date
    Aug 2016
    Posts
    290

    Default

    Yes you can have a regex for that purpose. But you would have better luck trying a regex forum, as this is not specific to kettle.

    Regex could look something like this: .*(\d{2}).*\d{2}:\d{2}

    Have you tried regex101.com?

  3. #3
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    If your string is a well-known date format, why not convert it from String to a date?
    You can then do all the useful functions on that including "Day of month of date"

    I almost always advocate coming in with the actual problem that you're trying to solve, not coming in asking how to implement a particular solution... RegEx is not always the best solution to a problem.

  4. #4

    Default

    Thanks All
    I used javascript step to get string between two commas.

    var test_day_start_date = DST_Start_March.substring(
    DST_Start_March.indexOf(",") + 1,
    DST_Start_March.lastIndexOf(",")
    );


    Then I used String operation step and Set "Digits" value to "Only".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.