File: crop_text.ps1

package info (click to toggle)
ruby-specinfra 2.94.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,464 kB
  • sloc: ruby: 10,562; makefile: 4
file content (11 lines) | stat: -rw-r--r-- 313 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
function CropText
{
  param($text, $fromPattern, $toPattern)
  
  $from, $to = ([regex]::matches($text, $fromPattern)), ([regex]::matches($text, $toPattern))
  if ($from.count -gt 0 -and $to.count -gt 0) {
    $text.substring($from[0].index, $to[0].index + $to[0].length - $from[0].index)
  } else {
    ""
  }
}