Re: regular expressions help



This is for a pipe delimited string of text using regular expressions.

On Jan 10, 9:03 am, supercrossk...@xxxxxxxxx wrote:
I will try to make it more clear.

1|2|3|this are is the text I want to display||a|b|||45.67|cd|don't
need this text
|||||||||||||||||||||||||| this text

I've tried some combinations of things to get exactly what I want, but
can't get it 100%.

([\w.]+\s*)?,?").Groups(1).ToString() only gets first item, number 1
in this case. I want the text "this are is the text I want to display"
and only that. The pattern is just like it is above, the first 3 are
digits, then some text(the text I want), empty, one alpha character,
etc in example.

On Jan 9, 3:29 pm, Ethan Strauss



<EthanStra...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am not sure I understand the question, but I think this will help.

You can create a named group by enclosing it in paranethsis and add ?<name>.

For example, I have the following Regex pattern in my code
"_(?<WellName>[A-H]\\d{1,2})_"

This is used to capture just the Well Designation (a letter from A-H and
then 1 or 2 digits) from a longer string as long as that pattern is
surrounded by underscores.

Regex.Match("SomeText_B7_MoreText","_(?<WellName>[A-H]\\d{1,2})_").Groups["­­WellName"].Value;

Would return "B7" (If I don't have a typo somewhere...)
Ethan

"supercrossk...@xxxxxxxxx" wrote:
I am trying to the values of string of text in the sample before. The
ds are for digits and s is for string and string of text is for a
string with more than one or two values. I am trying to use regex and
the .groups method. Please help.

d|d|d|string of text 1||s|s|||dd.dd|ss|string of text
2||||||||||||||||||||||||||string of text 2

I only want string of text1- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -

.



Relevant Pages

  • Re: How to convert extra long strings into their equivalent Hex Strings in VBA (Word 2K)
    ... numbers (upto 18 digits max) into its equivalent Hex String ... Public Function ExpressServiceCode(ByVal ServiceTag As String) As String ... 'the number dblTemp in the specified base, ... Dim lngTemp As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Trouble with $key to HASH when Numeric
    ... the end of a string -- in other words, this pattern will always match ... and capture either 5 digits or nothing; 2) the pattern is anchored to ... modifier, which you do not). ...
    (comp.lang.perl)
  • Re: what is the quickest way to find out whether a string contains another string?
    ... Why would anyone want to use regular expressions to look for a plain ... Regular expressions are a tool for deciding whether a String or ... searching is a trivial degeneration of the problem addressed by regular ... input string into a pattern that matches only itself is the first task. ...
    (comp.lang.java.programmer)
  • Re: BigNum -- Floating Point
    ... The 'N' is the number of decimal digits. ... The internal representation is really just a string of bits. ... the number of shifts for various multiples of ten: ... The 'exponent' is very closely related to ...
    (comp.programming)
  • Patterns in pi, copyright law, and philosophy
    ... Whether the offset of a string found in pi can be used as a form on ... then calculate how many digits of pi one would need to raise the ... "An infinite series of numbers is not an exhaustive set of numbers. ... finite string of digits occurs within the decimal expansion of pi, ...
    (sci.math)

Loading