Search Results

Search found 4498 results on 180 pages for 'expression'.

Page 44/180 | < Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >

  • How to replace the string based on an expression

    - by deepak
    I'm having a string where i'm using some placeholders to replace it with some values based on an object. It is like the following: Hello User <#= UserName #> I need to replace the <#= UserName # with a value. How can this be done with a regex? Please help. I dont want a string replace solution. There are somany placeholders and hardcoding the <#= UserName # and replace with the value is pointless

    Read the article

  • Multiline Regular Expression search and replace!

    - by Scott
    I've hit a wall. Does anybody know a good text editor that has search and replace like Notepad++ but can also do multi-line regex search and replace? Basically, I am trying to find something that can match a regex like: search oldlog\(.*\n\s+([\r\n.]*)\);replace newlog\(\1\) Any ideas?

    Read the article

  • regular expression for validation not working

    - by Camran
    I have a "description textarea" inside a form where user may enter a description for an item. This is validated with javascript before the form beeing submitted. One of the validation-steps is this: else if (!fld.value.match(desExp)){ And desExp: var desExp = /^\s*(\w[^\w]*){3}.*$/gm; Now my problem, this works fine on all cases except for descriptions where the description BEGINS with a special character of the swedish language (å, ä, ö). This wont work: åäö hello world But this will: hello world åäö Any fixes? Thanks

    Read the article

  • Regular Expression

    - by Blanca
    Hi! i would like to avoid texts like this one: height="49" with a regular expresion. I tought in .replaceAll("\s*="*"",""); (replaceAll is used as a method in a java class), but eclipse don't allowed me to do that. Any other suggestion?? tx!

    Read the article

  • Regular Expression: Match untill pattern is found

    - by ZafarYousafi
    Hi, I want to extract the status from the string untill I found a timespan. My input is something like "Something in start but not with this keyword of sure. STATUS: My Status Is Here Which can be anything but timespan 23:59:01 and so on. I want to extract the string after STATUS: untill 23:59:01 is found. How can i achieve this through regex. this 23:59:01 is a timespan and it is always in this format hh:mm:ss

    Read the article

  • Sed: regular expression match lines without <!--

    - by sixtyfootersdude
    I have a sed command to comment out xml commands sed 's/^\([ \t]*\)\(.*[0-9a-zA-Z<].*\)$/\1<!-- Security: \2 -->/' web.xml Takes: <a> <!-- Comment --> <b> bla </b> </a> Produces: <!-- Security: <a> --> <!-- Security: <!-- Comment --> --> // NOTE: there are two end comments. <!-- Security: <b> --> <!-- Security: bla --> <!-- Security: </b> --> <!-- Security: </a> --> Ideally I would like to not use my sed script to comment things that are already commented. Ie: <!-- Security: <a> --> <!-- Comment --> <!-- Security: <b> --> <!-- Security: bla --> <!-- Security: </b> --> <!-- Security: </a> --> I could do something like this: sed 's/^\([ \t]*\)\(.*[0-9a-zA-Z<].*\)$/\1<!-- Security: \2 -->/' web.xml sed 's/^[ \t]*<!-- Security: \(<!--.*-->\) -->/\1/' web.xml but I think a one liner is cleaner (?) This is pretty similar: http://stackoverflow.com/questions/436850/matching-a-line-that-doesnt-contain-specific-text-with-regular-expressions

    Read the article

  • Substitute all matches with values in Ruby regular expression

    - by Lewisham
    Hi all, I'm having a problem with getting a Ruby string substitution going. I'm writing a preprocessor for a limited language that I'm using, that doesn't natively support arrays, so I'm hacking in my own. I have a line: x[0] = x[1] & x[1] = x[2] I want to replace each instance with a reformatted version: x__0 = x__1 & x__1 = x__2 The line may include square brackets elsewhere. I've got a regex that will match the array use: array_usage = /(\w+)\[(\d+)\]/ but I can't figure out the Ruby construct to replace each instance one by one. I can't use .gsub() because that will match every instance on the line, and replace every array declaration with whatever the first one was. .scan() complains that the string is being modified if you try and use scan with a .sub()! inside a block. Any ideas would be appreciated!

    Read the article

  • Turning logical expression around

    - by BluePrint
    I have the following code: bool s = true; for (...; ...; ...) { // code that defines A, B, C, D // and w, x, y, z if (!(A < w) && s == true) { s = false; } if (!(B < x) && s == true) { s = false; } if (!(C < y) && s == true) { s = false; } if (!(D < z) && s == true) { s = false; } } This code is working well. However, I want to, for several (unimportant) reasons, change the code so that I can initiate s = false; and set it to true inside the if-statement. It tried the following: bool s = false; for (...; ...; ...) { // code that defines A, B, C, D // and w, x, y, z if (A >= w && s == false) { s = true; } if (B >= x && s == false) { s = true; } if (C >= y && s == false) { s = true; } if (D >= z && s == false) { s = true; } } However, this is not working properly as the code above is working. I know thought wrong somewhere in the logic, but I can't figure out where. Does anbyone see my probably obvious error? EDIT: Added three more if-statemets. Missed them since they were commented away.

    Read the article

  • Regular Expression Program

    - by david robers
    Hi I have the following text: SMWABCCA ABCCAEZZRHM NABCCAYJG XABCCA ABCCADK ABCCASKIYRH ABCCAKY PQABCCAK ABCCAKQ This method takes a regex in out by the user and SHOULD print out the Strings it applies to but seems to print out something completely different: private void matchIt(String regex) { Pattern p = Pattern.compile(regex); Matcher m = null; boolean found = false; for(int i = 0; i < data.length; i++){ m = p.matcher(data[i]); if(m.find()){ out.println(data[i]); found = true; } } if(!found){ out.println("Pattern Not Found"); } } When inputting "[C]" It outputs: SMWABCCA ABCCAEZZRHM NABCCAYJG XABCCA ABCCADK ABCCASKIYRH ABCCAKY PQABCCAK ABCCAKQ Any ideas why? I think I'm using m.find() improperly...

    Read the article

  • dropping characters from regular expression groups

    - by tcurdt
    The goal: I want to convert a number from the format "10.234,56" to "10234.56" Using this simple approach almost gets us there /([\d\.]+),(\d\d)/ => '\1.\2' The problem is that the first group of the match (of course) still contains the '.' character. So questions are: Is it possible to exclude a character from the group somehow? How would you solve this with a single regexp (I know this is a trivial problem when not using a single regexp)

    Read the article

  • jQuery validation required( dependency-expression ) only 1 input validating

    - by user331884
    <script type="text/javascript"> $(function () { $("#form1").validate(); $("#survey1 .response").rules("add", { required: function () { return $('#choices').val() != '' } }); }); </script> <form id="form1" runat="server"> <div id="survey1"> <asp:DropDownList ID="choices" runat="server"> <asp:ListItem Value="">--Select--</asp:ListItem> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> </asp:DropDownList> <hr /> Response 1<br /> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="6" CssClass="response"></asp:TextBox> <hr /> Response 2<br /> <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Rows="6" CssClass="response"></asp:TextBox> </div></form> Only the first textbox gets validated. Am I missing something?

    Read the article

  • regular expression - function body extracting

    - by Altariste
    Hi, In Python script,for every method definition in some C++ code of the form: return_value ClassName::MethodName(args) {MehodBody} ,I need to extract three parts: the class name, the method name and the method body for further processing. Finding and extracting the ClassName and MethodName is easy, but is there any simple way to extract the body of the method? With all possible '{' and '}' inside it? Or are regexes unsuitable for such task?

    Read the article

  • Why is writeSTRef faster than if expression?

    - by wenlong
    writeSTRef twice for each iteration fib3 :: Int -> Integer fib3 n = runST $ do a <- newSTRef 1 b <- newSTRef 1 replicateM_ (n-1) $ do !a' <- readSTRef a !b' <- readSTRef b writeSTRef a b' writeSTRef b $! a'+b' readSTRef b writeSTRef once for each iteration fib4 :: Int -> Integer fib4 n = runST $ do a <- newSTRef 1 b <- newSTRef 1 replicateM_ (n-1) $ do !a' <- readSTRef a !b' <- readSTRef b if a' > b' then writeSTRef b $! a'+b' else writeSTRef a $! a'+b' a'' <- readSTRef a b'' <- readSTRef b if a'' > b'' then return a'' else return b'' Benchmark, given n = 20000: benchmarking 20000/fib3 mean: 5.073608 ms, lb 5.071842 ms, ub 5.075466 ms, ci 0.950 std dev: 9.284321 us, lb 8.119454 us, ub 10.78107 us, ci 0.950 benchmarking 20000/fib4 mean: 5.384010 ms, lb 5.381876 ms, ub 5.386099 ms, ci 0.950 std dev: 10.85245 us, lb 9.510215 us, ub 12.65554 us, ci 0.950 fib3 is a bit faster than fib4.

    Read the article

  • python and regular expression with unicode

    - by bsn
    I need to delete some unicode symbols from the string '?????? ??????? ???????????? ??????????' I know they exist here for sure. I try: re.sub('([\u064B-\u0652\u06D4\u0670\u0674\u06D5-\u06ED]+)', '', '?????? ??????? ???????????? ??????????') but it doesn't work. String stays the same. ant suggestion what i do wrong?

    Read the article

  • Django store regular expression in DB which then gets evaluated on page

    - by John
    Hi, I want to store a number of url patterns in my django model which a user can provide parameters to which will create a url. For example I might store these 3 urls in my db where %s is the variable parameter provided by the user: www.thisissomewebsite.com?param=%s www.anotherurl/%s/ www.lastexample.co.uk?param1=%s&fixedparam=2 As you can see from these examples the parameter can appear anywhere in the string and not in a fixed position. I have 2 models, one holds the urls and one holds the variables: class URLPatterns(models.Model): pattern = models.CharField(max_length=255) class URLVariables(models.Model): pattern = models.ForeignKey(URLPatterns) param = models.CharField(max_length=255) What would be the best way to generate these urls by replacing the %s with the variable in the database. would it just be a simple replace on the string e.g: urlvariable = URLVariable.objects.get(pk=1) pattern = url.pattern url = pattern.replace("%s", urlvariable.param) or is there a better way? Thanks

    Read the article

  • Matching Word with regular expression

    - by lbar
    I have the following text file: ... "somewords MYWORD";123123123123 "someother MYWORDOTHER";456456456456 "somedifferent MYWORDDIFFERENT";789789789 ... i need to match the word MYWORD, MYWORDOTHER, MYWORDDIFFERENT and then substitute the space before this word with ";". Someone can figure out a regex? I have done something like that: +[^ ][^ ][^ ][^ ][^ ][^ ][^ ]"; but this works only with a specific word lenght. I need to modify to get any word of any leght. Any help? Thank you.

    Read the article

  • Regex if-else expression

    - by craig
    I'm trying to extract the # of minutes from a text field using Oracle's REGEXP_SUBSTR() function. Data: Treatment of PC7, PT1 on left. 15 min. 15 minutes. 15 minutes 15 mins. 15 mins 15 min. 15 min 15min 15 In each case, I'm hoping to extract the '15' part of the string. Attempts: \d+ gets all of the numeric values, including the '7' and '1', which is undesirable. (\d)+(?=\ ?min) get the '15' from all rows except the last. (?((\d)+(?=\ ?min))((\d)+(?=\ ?min))|\d+), an if-else statement, doesnt' match anything. What is wrong with my if-else statement?

    Read the article

  • Expected Expression

    - by coffeeaddict
    I cannot figure out what I did or did not do here syntactically to cause this error. I don't see what's missing: function ShowWaitMessage(button) { var isValid; if (buttonSelected()) { showWaitMessage(button, "showMessage1"); isValid = true; } else { Page_ClientValidate(); if (Page_IsValid) { showWaitMessage(button, "showMessage2"); isValid = true; } } return isValid; }

    Read the article

< Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >