• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Angle brackets in Powershell

 
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
So I have a powershell script that I need to rewrite as a linux shell script, but I don't understand part of the regular expressions that are used. The regex looks like this:

My question is what does ?<indent> mean? (for Google's sake, this is a question mark followed by angle brackets containing what I think is an identifier) It seems to be treated as an index into the regex matches...like so:

But I haven't been able to find any documentation on my friend Google explaining how this works, and whether it is a powershell specific feature or something that can be adapted to regular expressions in general. Does anyone know of a good resource for powershell that covers this information or can explain it here?

Thanks!
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After a little more looking, it seems that what I was thinking is right: the groups inside an individual regex can be named in powershell. As opposed to counting those groups with numbers.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's called a "named capturing group". I don't know much about PowerShell, but other languages do have them. They were added to Java, for instance, in Java 7 - see java.util.regex.Pattern (look for "Special constructs") and java.util.regex.Matcher#group(java.lang.String).
reply
    Bookmark Topic Watch Topic
  • New Topic