Re: Regex repeating capture



Sorry, this was a simple example. In all, there are 50+ identifiers
and * is allowed in that data as long it isn't immediately followed by
an identifier, otherwise it is considered another identifier.

On Jan 30, 11:58 am, "Peter Bradley" <pbrad...@xxxxxxxxxx> wrote:
Use:

public string[] Split (
params char[] separator
)
to split your string on the asterisk as a first step.

Now you can enumerate over the string array splitting out your identifiers
and data strings. You could use a StringBuilder to build what ever you want
to output.

Now you can use:

public bool StartsWith (
string value
)andpublic string Substring (
int startIndex
)e.g.StringBuilder sb = new StringBuilder();
foreach (string s in strArray)
{
if (s.StartsWith("CZ")
{
sb.Append("CZ");
sb.Append(s.Substring(2));
}
else
{
sb.Append("fuuu");
sb.Append(s.Substring(4))
}

}return sb.ToString();

I'm sure there's an easier way using a Regex, but I can't be bothered to
puzzle it out.

HTH

Peter

<jayluc...@xxxxxxxxx> wrote in messagenews:1170174574.488763.29890@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Howdy,

I'm trying to break an input string into multpile pieces using a
series of delimiters that start with an asterisk. Following the
asterisk is a mulitple character identifier immediately followed by a
data string of variable length. The input string may contain more than
one identifier anywhere in the string.

Here is an example:
*CZ1 2.3 4-56 *fuuuS24364 08 23 72

I'd like to break this into
CZ
1 2.3 4-56
fuuu
S24364 08 23 72

I have tried the pattern (?:\*(CZ|fuuu)(.*)), which produces the
following ouput:
CZ
1 2.3 4-56 *fuuuS24364 08 23 72

How can I force it to repeat the capturing?

Thanks,
Jay

.



Relevant Pages

  • Double Linked List Help
    ... 256 characters long identified in the input file F. Each identifier ... identifier, length is an integer representing the length of the ... string is a string of characters representing the identifier itself. ...
    (comp.lang.c.moderated)
  • Re: kde4 and opengl
    ... server glx vendor string: NVIDIA Corporation ... Identifier "Simple Layout" ...
    (comp.windows.x.kde)
  • Re: Countif in VB Script
    ... identifies/keeps track of its patients. ... However, they use a wrist band identifier, which is usually not subject ... The collection keeps track what it has stored by using a unique string ... colvalues.add vbNullString, CStr.value) ...
    (microsoft.public.excel.programming)
  • Re: Regex repeating capture
    ... series of delimiters that start with an asterisk. ... data string of variable length. ... one identifier anywhere in the string. ...
    (comp.lang.perl.misc)
  • Re: COM Collections/arrays accessed from JScript
    ... >> var mystring = child.xml ... > except that, using a string rather than an identifier, the latter syntax ... > need to code Invoke to recognize these special DISPIDs and redirect to a ...
    (microsoft.public.win32.programmer.ole)