github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/regexp.md (about)

     1  # `regexp`
     2  
     3  > Regexp tools for arrays / lists of strings
     4  
     5  ## Description
     6  
     7  `regexp` provides a few tools for text matching and manipulation against an
     8  array or list of strings - thus `regexp` is Murex data-type aware.
     9  
    10  ## Usage
    11  
    12  ```
    13  <stdin> -> regexp expression -> <stdout>
    14  ```
    15  
    16  ## Examples
    17  
    18  ### Find elements
    19  
    20  ```
    21  » ja [monday..sunday] -> regexp 'f/^([a-z]{3})day/'
    22  [
    23      "mon",
    24      "fri",
    25      "sun"
    26  ]
    27  ```
    28  
    29  This returns only 3 days because only 3 days match the expression (where
    30  the days have to be 6 characters long) and then it only returns the first 3
    31  characters because those are inside the parenthesis.
    32  
    33  ### Match elements
    34  
    35  Elements containing
    36  
    37  ```
    38  » ja [monday..sunday] -> regexp 'm/(mon|fri|sun)day/'
    39  [
    40      "monday",
    41      "friday",
    42      "sunday"
    43  ]
    44  ```
    45  
    46  Elements excluding
    47  
    48  ```
    49  » ja [monday..sunday] -> !regexp 'm/(mon|fri|sun)day/'
    50  [
    51      "tuesday",
    52      "wednesday",
    53      "thursday",
    54      "saturday"
    55  ]
    56  ```
    57  
    58  ### Substitute expression
    59  
    60  ```
    61  » ja [monday..sunday] -> regexp 's/day/night/'
    62  [
    63      "monnight",
    64      "tuesnight",
    65      "wednesnight",
    66      "thursnight",
    67      "frinight",
    68      "saturnight",
    69      "sunnight"
    70  ]
    71  ```
    72  
    73  ## Flags
    74  
    75  * `f`
    76      output found expressions (doesn't support bang prefix)
    77  * `m`
    78      output elements that match expression (supports bang prefix)
    79  * `s`
    80      output all elements - substituting elements that match expression (doesn't support bang prefix)
    81  
    82  ## Detail
    83  
    84  `regexp` is data-type aware so will work against lists or arrays of whichever
    85  Murex data-type is passed to it via STDIN and return the output in the
    86  same data-type.
    87  
    88  ## Synonyms
    89  
    90  * `regexp`
    91  * `!regexp`
    92  * `list.regex`
    93  
    94  
    95  ## See Also
    96  
    97  * [`2darray` ](../commands/2darray.md):
    98    Create a 2D JSON array from multiple input sources
    99  * [`a` (mkarray)](../commands/a.md):
   100    A sophisticated yet simple way to build an array or list
   101  * [`append`](../commands/append.md):
   102    Add data to the end of an array
   103  * [`count`](../commands/count.md):
   104    Count items in a map, list or array
   105  * [`ja` (mkarray)](../commands/ja.md):
   106    A sophisticated yet simply way to build a JSON array
   107  * [`jsplit` ](../commands/jsplit.md):
   108    Splits STDIN into a JSON array based on a regex parameter
   109  * [`map`](../commands/map.md):
   110    Creates a map from two data sources
   111  * [`match`](../commands/match.md):
   112    Match an exact value in an array
   113  * [`msort`](../commands/msort.md):
   114    Sorts an array - data type agnostic
   115  * [`prefix`](../commands/prefix.md):
   116    Prefix a string to every item in a list
   117  * [`prepend`](../commands/prepend.md):
   118    Add data to the start of an array
   119  * [`pretty`](../commands/pretty.md):
   120    Prettifies JSON to make it human readable
   121  * [`suffix`](../commands/suffix.md):
   122    Prefix a string to every item in a list
   123  * [`ta` (mkarray)](../commands/ta.md):
   124    A sophisticated yet simple way to build an array of a user defined data-type
   125  
   126  <hr/>
   127  
   128  This document was generated from [builtins/core/lists/regexp_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/lists/regexp_doc.yaml).