Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:30:16+00:00 2026-06-11T14:30:16+00:00

What Im Building: The script archives a working directory using GIT-POSH and sends it

  • 0

What Im Building:

The script archives a working directory using GIT-POSH and sends it to a Linux Apache Server using a Windows Powershell SSH Module.

For convenience, the script also needs to do reporting on existing files on the local machine as well as the Apache server.

The Problem:

This is where I need string manipulation to separate each block in the naming convention.

I was going to use underscores block_block until I realized some of the blocks contain underscores them already.
This is when I decided to encapsulate each block with brackets [block][block]

In PHP I would use preg_split to pull out each piece into an associative array.

[product][branch_name][date][time][commit_hash]

Expected Usage:

--> Get-Product $string
--> product123
--> Get-Branch $string
--> branch123

Questions I have:

  • How do I preg_split this string the same way using powershell and apache?
  • A better naming convention that supports the same operation?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:30:18+00:00Added an answer on June 11, 2026 at 2:30 pm

    PHP’s preg_split can be mimicked with System.RegularExpressions.Split(). There are some caveats, namely Split() will return empty strings for tokens it replaced, so some filtering is needed. Like so,

    $data = "[product][branch_name][date][time][commit_hash]"
    $arr = [Regex]::Split($data, "[\[\]]") | ? { $_.length -gt 0 }
    $arr
    

    Output:

    product
    branch_name
    date
    time
    commit_hash
    

    Without the filtering clause ? { $_.length -gt 0 } – which will exclude string objects that have length of zero – the output would be slightly different:

    product
    
    branch_name
    
    date
    
    time
    
    commit_hash
    

    This behaivour is documented in MSDN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a PHP script that sends an email to people on their birthdays.
I'm building a Powershell script to manage distribution groups and contacts. But when I
At the moment I'm building a login Script on powershell basis. This login script
I am building a script for users new to Linux, so please understand why
A php script is building the following (very complicated script that is too long
I´m building a bash script and i want to replace ${PRODUCT_NAME} with a WORD
I am building a build script for our web development team. We will be
I've got a custom ant script for building and other fun stuff. IntelliJ has
I read the tutorial, https://developers.google.com/apps-script/articles/building-sites-app-part2 that uses spreadsheet service in Google sites. The code
I'm building an automated install script for Hadoop, and I'm encountering an issue where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.