.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

How to pass value to replace reg expression...........

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :ASP.Net
 

I am having string there i have replace some characters.

 

var rep =' this the text i have to replace, this is the only one'

 

var k ='this'

 

rep.replace(/k/gi,'how')

 

how to achieve this...............

 




View Complete Post


More Related Resource Links

Regular expression: Replace anything that isn't alphanumeric with a space?

  
Hi there,I'm writing a function in C# that will clean up a filename that a user might upload.One of the requirements is to replace any character that isn't alphanumeric with a space, but I can't seem to get the regular expression working to do so?I've include my code below, thanks for any help :)// Replace miscellaneous characters with a space inputFilenameRegex = new Regex(@"^[a-zA-Z0-9]"); inputFilename = inputFilenameRegex.Replace(inputFilename, " ");

Web expression 3 and find/replace with a regular expression

  
I'm am trying to  delete some code in a javascript

<a href="JavaScript:openPopImg('images/Burgess-Rufus1.jpg', 'Rufus Morgan Burgess', '296', '589')">  I want to delete  ', 'xxx', 'xxx')  throughout the web.  I can not get  a regular expression going that will work; .i.e.  ^(\'\, \'[0-9]{3,}\'\, \'[0-9]{3,}\' \)) Am I anywhere near right or is there another way to do this?  Thanks.

1.)Duplicating VB Right() functionality 2.) Seek and replace multiple expressions in a single pass?

  
Two questions:
1. I want to replicate the functionality of the Right() string function in Regex in order to lop off the first four characters of certain 20 character strings if those leading characters happen to be "K3AH". Right(string,16) would be part of the VB code I'd use to do it but this is what I've come up with using Regex:

Dim re As New Regex("\bK3AH+(?=\d{16})", RegexOptions.Multiline)

Dim source$ = "SRA-7138-29		K3AH1241091742015390	K3AH1241170743153764	6454	dawni001"

source$ = re.Replace(source$, "")
And it seems to work, returning "SRA-7138-29  1241091742015390AH1241170743153764 6454 dawni001"

Is there a better (i.e.,faster, safer, whatever) way to do this?


2. Is it possible, using Regex, to search for multiple (different) expressions and make replacement for all of them while only makin a single pass through a text file?

Regular expression or logic to replace UL LI tags

  

Hi All,

I have HTML which can contain ordered lists like

<ul>
    <li>a
    <ul>
        <li>l</li>
        <li>m
        <ul>
            <li>x</li>
            <li>y</li>
        </ul>
        </li>
        <li>n</li>
    </ul>
    </li>
    <li>b</li>
</ul>

resulting as

  • a
    • l
    • m
      • x
      • y
    • n
  • b
  • I want to achieve following replacement

    firstLevel li with bullet (for which I will find the character)

    secondLevel li with circled bullet (for which I will find the character)

    thirdLevel li with squared bullet (for which I will find the character)

     Can this be achieved with regular expressions? Please note contents can be dynamic

    Regular expression to replace
    and
    tags

      

    Hi Everybody,

    I have an HTML with content some thing like

    <div style="margin-left: 40px">a <strong>b </strong><em><strong>c</strong></em></div>

    What I want to achieve is

    <div style="margin-left: 40px"> to be replaced with &#09;

    And </div> with &nbsp;<br> without touching inside contents which are dynamic

    I thought this can be achieved using regular expression Regex.Replace but not worked on regular expression.

    Can anyone help with proper approach?

    Thanks!

     


    replace tab in the string using regular expression

      
    hi,
          I want to replace tab space with "|" in the string using regular expressions.
    I have tried for

    Dim strTabString AS string = "A             B             C "                 
    TextBox1.Text = Regex.Replace(strTabString , "\t", "|")
    But i m not getting the results.

    Thanks.

    How to use lambda expression to replace if-else

      

    I have a list of possible nodes as a child of parent node, i need to compare the nodeName and if node name matches, i need to get the value and assign it to member variable.

    public class Contacts
    {
    private string FirstName;
    private string LastName;
      public LoadContacts(XmlNode contactNode)
      {
        string[] names={
         FirstName,
         LastName,
         PhoneNumber,
         Address
        }
        foreach(XmlNode child in contactNode)
       {
         
         if( child.Name == names[0])
           m_firstName = child.Value;
         else
         if(child.Name == names[1])
           m_lastName = child.Value;
         else...
     
        }
     }
    

    Is there a way of re-factor the same code with Lambda expression.

    Thanks in Advance.


    C--s

    Replace on conditional expression

      

    Hi Guys,

    I need to replace empty or null columns with this string word “RETURN”

    However the requirement is conditional base, example like below

    Column Names :[Flag],  [QTY] and [State]

    Date Type: [FLAG] [DT_WSTR,25]

                       [QTY] (DT_R4]

                        [state] [DT_WSTR,25]

    All I want is whenever FLAG == “I” && [QTY] < 0, then the STATE has to replace with “RETURN”.

     

    Thanks,


    D


    How to pass control reference to its property in data binding expression

      

    Here is data binding expression (dropdown list is nested in gridview)

    <asp:DropDownList ID="ddlEmployees" 
             runat="server" 
             DataSource='<%# PayCheckBO.GetEmployeesNameIdPair() %>' 
             DataTextField="Text" 
             DataValueField="Value" 
             SelectedIndex='<%# GetSelectedIndex(HOW TO PASS REF of ddlemployee HERE)%>'/>

    Code Behind has function which looks like

    public int GetSelectedIndex(DropDownList ddl)
    {
            //loop through the item in the dropdownlist
            //return index based on xyz checks
    }

    The whole reason for passing the reference is to save round trip to database and not to use SESSION


    How to Pass Values Between Web Pages ASP.NET

      
    You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

    Use a query string.

    Get HTTP POST information from the source page.

    The following options are available only when the source and target pages are in the same ASP.NET Web application.

    Use session state.

    Create public properties in the source page and access the property values in the target page.

    Get control information in the target page from controls in the source page.

    How to Pass Values Between ASP.NET Web Pages

      
    You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web page:

    Use a query string.

    Get HTTP POST information from the source page.

    The following options are available only when the source and target pages are in the same ASP.NET Web application.

    Use session state.

    Create public properties in the source page and access the property values in the target page.

    Get control information in the target page from controls in the source page.

    pass value from textbox to action, formcollection best way here?

      

    Hi I'm building a e-commerce store and on quantity of product I'm going with a textbox. I thought I would ask how would you do this? a viewmodel to use a strongly typed textbox or just get the value of the textbox from the formscollection passed in to the action?


    Thanks for any input


    Pass a grid column value to a Modal

      

    Hi, I have a requirement to hide a field called details on a gridview and show it in a jQuery modal dialog when users click on the Customer ID hyperlink. This grid is created programmatically. I will be hiding the details column via the CSS display:none property. Does some one know how can I pass the grid's selected hidden column value to the modal? Here is some of the code I started:

                GridView mygrid = new GridView();
                //.....................................More columns code for the grid

                //Here is where I need to pass the Details column value associated with the customer ID field selected to the Modal and open the Modal dialog.            
                HyperLinkField linkField = new HyperLinkField();
                string[] dataNavigateUrlFields = { "CustomerID" };
                linkField.DataTextField = "CustomerID";
                linkFi

    Pass ASP.NET membership identity object across domain?

      

    I am trying to figure a way to SSO with ASP.NET membership and role model.

    I can implement custom membership provider which consume web services hosting on a server.

    With encryption of data. No problem.

    But my question is, If I sign on a website with my provider, got my identity object on that application,

    could I pass it to another website on another domain which use the same provider and by doing so, do not need to login again?


    If this is possible, I am going to implement this solution. Please tell me what's your take on this.


    How to pass value to another form

      

    Dear experts,

                         I have QuoteNumber filed in Db.aspx(ddquote.txt) i want to pass this QuoteNumber values(values should to another web form/page i.e. mail.aspx when i click mail button, Message should supposed to display in textbox(txtQuote.txt) of mail.aspx form/page is "You are sending "QuoteNumber"  quotation to "MailID", Thanks.

     

     

     


    Can I replace the EntityObject as base-class in Entity Designer 3.5 sp1?

      

    I'm using EF3.5sp1 for a project, and I've been working around many of its problems... as such, my entity partial classes have a lot of logic in them for change-tracking and whatnot.  Obviously, I'd like to factor this logic out into a common base class, but of course all my objects must derive from EntityObject.  Is it possible to tell them to derive from some class of my own invention (which would actually likely derive from EntityObject themselves)?

    I'd rather avoid editing the EDMX file unless the changes will be safe on entity-model-update, since I'm still making changes to the database schema in this early state of my project.

    Thanks

    Also, is there any good workaround for the fact that the change isn't tracked when you change EntityReference.EntityKey?


    How to retrieve data from SqlDataSource and pass to a variable?

      

    Hi there,

    I have a page in my website where there is very little code-behind. I only have two lines of code in Page_Load() and the rest of the code is declarative ASP.NET code. I have a FormView control which uses a SqlDataSource to get some order information. The SqlDataSource calls a stored procedure called usp_GetOrderDetails, here's the code for the SqlDataSource:

        <asp:SqlDataSource ID="sdsFormOrderDetails" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ForexDB %>"
    ProviderName="<%$ ConnectionStrings:ForexDB.ProviderName %>"
    SelectCommand="usp_GetOrderDetails" SelectCommandType="StoredProcedure"
    UpdateCommand="usp_UpdateOrder" UpdateCommandType="StoredProcedure"
    >
    <SelectParameters>
    <asp:ControlParameter Name="orderId" ControlID="grdOrders" PropertyName="SelectedDataKey.Value" />
    </SelectParameters>
    <UpdateParameters>
    <asp:ControlParameter Name="orderId" ControlID="frmOrderDetails" PropertyName="SelectedValue" />
    </UpdateParameters>
    </asp:SqlDataSource>
    Categories: 
    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend