473,898 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex inside of a tag

Is there a way to use Regex inside of a tag, such as asp:label?

I tried something like this but can't make it work:

<asp:label id="Phone" text=Regex.Repl ace('<%# Container.DataI tem("Phone")
%>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>

I have this inside my Repeater and want it to filter the field during bind.
I can do it afterwards by just looping through the repeater items, but that
is extra work and time.

Thanks,

Tom
Nov 19 '05 #1
6 1784
try wrapping it around the Container.DataI tem("Phone") section, rather than
the text section
--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"tshad" <tf*@dslextreme .com> wrote in message
news:ep******** ******@tk2msftn gp13.phx.gbl...
Is there a way to use Regex inside of a tag, such as asp:label?

I tried something like this but can't make it work:

<asp:label id="Phone" text=Regex.Repl ace('<%# Container.DataI tem("Phone")
%>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>

I have this inside my Repeater and want it to filter the field during
bind.
I can do it afterwards by just looping through the repeater items, but
that
is extra work and time.

Thanks,

Tom

Nov 19 '05 #2

"John Timney (ASP.NET MVP)" <ti*****@despam med.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
try wrapping it around the Container.DataI tem("Phone") section, rather
than the text section
I thought that was what I was doing? Did I miss something?

Tom

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"tshad" <tf*@dslextreme .com> wrote in message
news:ep******** ******@tk2msftn gp13.phx.gbl...
Is there a way to use Regex inside of a tag, such as asp:label?

I tried something like this but can't make it work:

<asp:label id="Phone" text=Regex.Repl ace('<%# Container.DataI tem("Phone")
%>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>

I have this inside my Repeater and want it to filter the field during
bind.
I can do it afterwards by just looping through the repeater items, but
that
is extra work and time.

Thanks,

Tom


Nov 19 '05 #3

meaning

<asp:label id="Phone" text='<%# Regex.Replace(C ontainer.DataIt em("Phone")
,"(\d{3})(\d{3} )(\d{4})","($1) $2-$3") %>' runat="server"/>

Sreejith

"tshad" wrote:

"John Timney (ASP.NET MVP)" <ti*****@despam med.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
try wrapping it around the Container.DataI tem("Phone") section, rather
than the text section


I thought that was what I was doing? Did I miss something?

Tom


--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"tshad" <tf*@dslextreme .com> wrote in message
news:ep******** ******@tk2msftn gp13.phx.gbl...
Is there a way to use Regex inside of a tag, such as asp:label?

I tried something like this but can't make it work:

<asp:label id="Phone" text=Regex.Repl ace('<%# Container.DataI tem("Phone")
%>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>

I have this inside my Repeater and want it to filter the field during
bind.
I can do it afterwards by just looping through the repeater items, but
that
is extra work and time.

Thanks,

Tom



Nov 19 '05 #4
"Sreejith Ram" <Sr*********@di scussions.micro soft.com> wrote in message
news:96******** *************** ***********@mic rosoft.com...

meaning

<asp:label id="Phone" text='<%# Regex.Replace(C ontainer.DataIt em("Phone")
,"(\d{3})(\d{3} )(\d{4})","($1) $2-$3") %>' runat="server"/>

That worked great.

Here is what I was doing it. I first get the data in my Repeater:

<asp:label ID="Wages" text='<%#
Regex.Replace(C ontainer.DataIt em("Wages"),"\-|\,",""),"(\d{3 })(\d{3})(\d{4} )
","($1) $2-$3" %>' runat="server"/>
Then I go through the RepeaterItem list and filter the phone numbers.

for each oItem as RepeaterItem in ExperienceRepea ter.items
oLabel = Ctype(oItem.Fin dControl("Phone "),Label)
oLabel.Text = Regex.Replace(R egex.Replace(oL abel.Text,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")
next

If I replace the Regex line into the Repeater, as you show:

<asp:label ID="Wages" text='<%#
Regex.Replace(R egex.Replace(Co ntainer.DataIte m("Phone"),"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3" %>' runat="server"/>

It works fine.

What about a BoundColumn?

I tried changing my Bound Column:

<asp:BoundColum n DataField=Conta ctPhone
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">

and replaced it with:

<asp:BoundColum n DataField='Rege x.Replace(Regex .Replace(Contac tPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")'
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">

but got the error:

A field or property with the name
'Regex.Replace( Regex.Replace(C ontactPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")' was not found on the selected
datasource.

Do I have to use a TemplateColumn and use an asp:Label?

Thanks,

Tom
Sreejith

"tshad" wrote:

"John Timney (ASP.NET MVP)" <ti*****@despam med.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
try wrapping it around the Container.DataI tem("Phone") section, rather
than the text section


I thought that was what I was doing? Did I miss something?

Tom


--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"tshad" <tf*@dslextreme .com> wrote in message
news:ep******** ******@tk2msftn gp13.phx.gbl...
> Is there a way to use Regex inside of a tag, such as asp:label?
>
> I tried something like this but can't make it work:
>
> <asp:label id="Phone" text=Regex.Repl ace('<%# Container.DataI tem("Phone")> %>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>
>
> I have this inside my Repeater and want it to filter the field during
> bind.
> I can do it afterwards by just looping through the repeater items, but> that
> is extra work and time.
>
> Thanks,
>
> Tom
>
>



Nov 19 '05 #5
<asp:BoundColum n DataField='Rege x.Replace(Regex .Replace(Contac tPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")'
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">
Above wouldnt work.. wrong usage..
I believe, you will be able to create a TemplateColumn as below

<asp:TemplateCo lumn>

<ItemTemplate >
<asp:label id="Phone" text='<%#
Regex.Replace(C ontainer.DataIt em("Phone")
,"(\d{3})(\d{3} )(\d{4})","($1) $2-$3") %>' runat="server"/>
</ItemTemplate>

<asp:TemplateCo lumn>
Sreejith


"tshad" wrote:
"Sreejith Ram" <Sr*********@di scussions.micro soft.com> wrote in message
news:96******** *************** ***********@mic rosoft.com...

meaning

<asp:label id="Phone" text='<%# Regex.Replace(C ontainer.DataIt em("Phone")
,"(\d{3})(\d{3} )(\d{4})","($1) $2-$3") %>' runat="server"/>


That worked great.

Here is what I was doing it. I first get the data in my Repeater:

<asp:label ID="Wages" text='<%#
Regex.Replace(C ontainer.DataIt em("Wages"),"\-|\,",""),"(\d{3 })(\d{3})(\d{4} )
","($1) $2-$3" %>' runat="server"/>
Then I go through the RepeaterItem list and filter the phone numbers.

for each oItem as RepeaterItem in ExperienceRepea ter.items
oLabel = Ctype(oItem.Fin dControl("Phone "),Label)
oLabel.Text = Regex.Replace(R egex.Replace(oL abel.Text,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")
next

If I replace the Regex line into the Repeater, as you show:

<asp:label ID="Wages" text='<%#
Regex.Replace(R egex.Replace(Co ntainer.DataIte m("Phone"),"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3" %>' runat="server"/>

It works fine.

What about a BoundColumn?

I tried changing my Bound Column:

<asp:BoundColum n DataField=Conta ctPhone
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">

and replaced it with:

<asp:BoundColum n DataField='Rege x.Replace(Regex .Replace(Contac tPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")'
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">

but got the error:

A field or property with the name
'Regex.Replace( Regex.Replace(C ontactPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")' was not found on the selected
datasource.

Do I have to use a TemplateColumn and use an asp:Label?

Thanks,

Tom
Sreejith

"tshad" wrote:

"John Timney (ASP.NET MVP)" <ti*****@despam med.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
> try wrapping it around the Container.DataI tem("Phone") section, rather
> than the text section

I thought that was what I was doing? Did I miss something?

Tom
>
>
> --
> Regards
>
> John Timney
> ASP.NET MVP
> Microsoft Regional Director
>
> "tshad" <tf*@dslextreme .com> wrote in message
> news:ep******** ******@tk2msftn gp13.phx.gbl...
>> Is there a way to use Regex inside of a tag, such as asp:label?
>>
>> I tried something like this but can't make it work:
>>
>> <asp:label id="Phone" text=Regex.Repl ace('<%# Container.DataI tem("Phone") >> %>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>
>>
>> I have this inside my Repeater and want it to filter the field during
>> bind.
>> I can do it afterwards by just looping through the repeater items, but >> that
>> is extra work and time.
>>
>> Thanks,
>>
>> Tom
>>
>>
>
>


Nov 19 '05 #6
"Sreejith Ram" <Sr*********@di scussions.micro soft.com> wrote in message
news:58******** *************** ***********@mic rosoft.com...
<asp:BoundColum n DataField='Rege x.Replace(Regex .Replace(Contac tPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")'
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">
Above wouldnt work.. wrong usage..
I believe, you will be able to create a TemplateColumn as below


You're right.

That seems to be the case. I found that since I have been leaning more
towards formatting on the client side, that I making more use of the
templateColumn and less of the BoundColumn.

Thanks,

Tom
<asp:TemplateCo lumn>

<ItemTemplate >
<asp:label id="Phone" text='<%#
Regex.Replace(C ontainer.DataIt em("Phone")
,"(\d{3})(\d{3} )(\d{4})","($1) $2-$3") %>' runat="server"/>
</ItemTemplate>

<asp:TemplateCo lumn>
Sreejith


"tshad" wrote:
"Sreejith Ram" <Sr*********@di scussions.micro soft.com> wrote in message
news:96******** *************** ***********@mic rosoft.com...
>
> meaning
>
> <asp:label id="Phone" text='<%#
> Regex.Replace(C ontainer.DataIt em("Phone")
> ,"(\d{3})(\d{3} )(\d{4})","($1) $2-$3") %>' runat="server"/>
>


That worked great.

Here is what I was doing it. I first get the data in my Repeater:

<asp:label ID="Wages" text='<%#
Regex.Replace(C ontainer.DataIt em("Wages"),"\-|\,",""),"(\d{3 })(\d{3})(\d{4} )
","($1) $2-$3" %>' runat="server"/>
Then I go through the RepeaterItem list and filter the phone numbers.

for each oItem as RepeaterItem in ExperienceRepea ter.items
oLabel = Ctype(oItem.Fin dControl("Phone "),Label)
oLabel.Text = Regex.Replace(R egex.Replace(oL abel.Text,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")
next

If I replace the Regex line into the Repeater, as you show:

<asp:label ID="Wages" text='<%#
Regex.Replace(R egex.Replace(Co ntainer.DataIte m("Phone"),"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3" %>' runat="server"/>

It works fine.

What about a BoundColumn?

I tried changing my Bound Column:

<asp:BoundColum n DataField=Conta ctPhone
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">

and replaced it with:

<asp:BoundColum n
DataField='Rege x.Replace(Regex .Replace(Contac tPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")'
HeaderText="Pho ne"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign=" Top"
SortExpression= "ContactPho ne">

but got the error:

A field or property with the name
'Regex.Replace( Regex.Replace(C ontactPhone,"\-|\
",""),"(\d{3})( \d{3})(\d{4})", "($1) $2-$3")' was not found on the
selected
datasource.

Do I have to use a TemplateColumn and use an asp:Label?

Thanks,

Tom
> Sreejith
>
> "tshad" wrote:
>
> >
> > "John Timney (ASP.NET MVP)" <ti*****@despam med.com> wrote in message
> > news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
> > > try wrapping it around the Container.DataI tem("Phone") section,
> > > rather
> > > than the text section
> >
> > I thought that was what I was doing? Did I miss something?
> >
> > Tom
> > >
> > >
> > > --
> > > Regards
> > >
> > > John Timney
> > > ASP.NET MVP
> > > Microsoft Regional Director
> > >
> > > "tshad" <tf*@dslextreme .com> wrote in message
> > > news:ep******** ******@tk2msftn gp13.phx.gbl...
> > >> Is there a way to use Regex inside of a tag, such as asp:label?
> > >>
> > >> I tried something like this but can't make it work:
> > >>
> > >> <asp:label id="Phone" text=Regex.Repl ace('<%#

Container.DataI tem("Phone")
> > >> %>',"(\d{3})(\d {3})(\d{4})","( $1) $2-$3") runat="server"/>
> > >>
> > >> I have this inside my Repeater and want it to filter the field
> > >> during
> > >> bind.
> > >> I can do it afterwards by just looping through the repeater items,

but
> > >> that
> > >> is extra work and time.
> > >>
> > >> Thanks,
> > >>
> > >> Tom
> > >>
> > >>
> > >
> > >
> >
> >
> >


Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3210
by: JS | last post by:
I am writing a C# app that needs to parse a sentence entered by the user for a simple boolean search. I need to capture all of the AND words that are not inside of double quotes. However, I am having a heck of a time figuring out a regex for it. Can anyone assist with a regex to find all the AND's not in double quotes? An example sentence might be: red and blue and "crazy elephant" and "orange and red" and stuff.
5
5114
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated by a tool. ' Runtime Version: 1.1.4322.2032 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </autogenerated>
13
2389
by: Chris Lieb | last post by:
I am trying to write a regex that will parse BBcode into HTML using JavaScript. Everything was going smoothly using the string class replace() operator with regex's until I got to the list tag. Implementing the list tag itself was fairly easy. What was not was trying to handle the list items. For some reason, in BBcode, they didn't bother defining an end tag for a list item. I guess that they designed it with bad old HTML 3.2 in mind...
2
2890
by: Tim_Mac | last post by:
hi, i have a tricky problem and my regex expertise has reached its limit. i have read other posts on this newsgroup that pull out the plain text from a html string, but that won't work for me because i want to preserve the html, and replace some of the plain text. i basically want to show the user's search terms highlighted in the page, like google does, but i want to do this server side (i have the mechanics of intercepting the html...
4
2651
by: Chris | last post by:
Hi Everyone, I am using a regex to check for a string. When all the file contains is my test string the regex returns a match, but when I embed the test string in the middle of a text file a match is never returned. The string that I give to the regex is one that contains the entire contents of a text file. I'm using the multi-line option and I've also tried stripping out the VbCr
4
2020
by: Marcus | last post by:
Hello, I am trying to include the literal '\' (backslash) character in a regex. I am not sure if I need to escape it, however... From http://www.regular-expressions.info/charclass.html: "To include a backslash as a character without any special meaning inside a character class, you have to escape it with another backslash. matches a backslash or an x."
9
8907
by: conspireagainst | last post by:
I'm having quite a time with this particular problem: I have users that enter tag words as form input, let's say for a photo or a topic of discussion. They are allowed to delimit tags with spaces and commas, and can use quotes to encapsulate multiple words. An example: tag1, tag2 tag3, "tag4 tag4, tag4" tag5, "tag6 tag6" So, as we can see here anything is allowed, but the problem is that splitting on commas obviously destroys tag4...
2
1690
by: natebruneau | last post by:
I wrote this regex <font>.*\((?<Inside>.*?)\)</font> "<font(Hi there)</font></font><font(Hi there)</font><font(Hi there)</font><font(Hi there)</font><font(Hi there)</font>" However it only returns the whole thing <font(Hi there)</font></font><font(Hi there)</font><font(Hi there)</font><font(Hi there)</font><font(Hi there)</fontas a
1
1891
by: anglaissam | last post by:
I have a regex that is designed to help improve readability for a html document. "(?=((?!<\/?em).)*<\/em>) The purpose of this regex is to escape " marks from within <EM> affected sentences. Example: Before: <P>This "is" <EM>a <STRONG>"Test"</STRONG></EM></P> After: <P>This "is" <EM>a <STRONG></EM>"<EM>Test</EM>"<EM></STRONG></EM></P> Note the regex only affects " inside of <EM> elements. My problem is that i need to modify the regex to...
0
9993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9840
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10857
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10483
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5880
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.