Search Results

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

Page 29/180 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • Regular Expression to return the contents of a HTML tag received as a string of text

    - by Nathan Hernandez
    I have a string in my code that I receive that contains some html tags. It is not part of the HTML page being displayed so I cannot grab the html tag contents using the DOM (i.e. document.getElementById('tag id').firstChild.data); So, for example within the string of text would appear a tag like this: 12 My question is how would I use a regular expression to access the '12' numeric digit in this example? This quantity could be any number of digits (i.e. it is not always a double digit). I have tried some regular expressions, but always end up getting the full span tag returned along with the contents. I only want the '12' in the example above, not the surrounding tag. The id of the tags will always be 'myQty' in the string of text I receive. Thanks in advance for any help!

    Read the article

  • python: multiline regular expression

    - by facha
    Hi, everyone I have a piece of text and I've got to parse usernames and hashes out of it. Right now I'm doing it with two regular expressions. Could I do it with just one multiline regular expression? #!/usr/bin/env python import re test_str = """ Hello, UserName. Please read this looooooooooooooooong text. hash Now, write down this hash: fdaf9399jef9qw0j. Then keep reading this loooooooooong text. Hello, UserName2. Please read this looooooooooooooooong text. hash Now, write down this hash: gtwnhton340gjr2g. Then keep reading this loooooooooong text. """ logins = re.findall('Hello, (?P<login>.+).',test_str) hashes = re.findall('hash: (?P<hash>.+).',test_str)

    Read the article

  • ASP.NET 4.0 Route expression builder inside Listview control

    - by Carlos Lone
    One of the features of ASP.NET 4.0 is Route Expression builder which allows you to set up hyperlinks like this: <asp:HyperLink runat="server" NavigateUrl="<%$ RouteUrl:RouteName=productos,categoria=Cereales,id=2 %>" >Productos</asp:HyperLink> Now I'm wondering if I can use this sort of syntax inside a ListView Control, I know is possible, but the tricky thing is that I want to genereate de route key value dynamically. So instead to write id=2 I would like to write id=<%# Eval("CategoryID") % . Can I do that?, if so, how should I write it. Thanks for your help!

    Read the article

  • Use 'let' in 'if' expression

    - by demas
    I need a function that works like this: foo :: Integer -> Integer -> [Integer] foo a b = do let result = [] let Coord x y = boo a b if x > 0 let result = result ++ [3] if y > 0 let result = result ++ [5] if x < a let result = result ++ [7] if y < b let result = result ++ [9] result I can not use the guards because the result can have more then one element. But as I see I can not use 'let' in the 'if' expression: all_possible_combinations.hs:41:14: parse error on input `let' How can I check multiple expressions and add new elements in the list? I search not only imperative solution, but the functional one.

    Read the article

  • Result of expression 'xxxx' is not a constructor in JS

    - by Pselus
    Trying to create an object in Javascript (for Appcelerator/Titanium). The "object" is defined like this: function server () { this.cacheimages = 0; this.login = ""; this.name = ""; this.root = ""; this.signup = ""; this.useimages = 0; this.userexists = ""; this.isdefault = 0; return this; } In the same file, in another function when I run this line: var server = new server(); I get the error Result of expression 'server' is not a constructor. I have tried it with and without the "return" line, neither work. What am I doing wrong?

    Read the article

  • ms-access: missing operator in query expression

    - by every_answer_gets_a_point
    i have this sql statement in access: SELECT * FROM (SELECT [Occurrence Number], [1 0 Preanalytical (Before Testing)], NULL, NULL,NULL FROM [Lab Occurrence Form] WHERE NOT ([1 0 Preanalytical (Before Testing)] IS NULL) UNION SELECT [Occurrence Number], NULL, [2 0 Analytical (Testing Phase)], NULL,NULL FROM [Lab Occurrence Form] WHERE NOT ([2 0 Analytical (Testing Phase)] IS NULL) UNION SELECT [Occurrence Number], NULL, NULL, [3 0 Postanalytical ( After Testing)],NULL FROM [Lab Occurrence Form] WHERE NOT ([3 0 Postanalytical ( After Testing)] IS NULL) UNION SELECT [Occurrence Number], NULL, NULL,NULL [4 0 Other] FROM [Lab Occurrence Form] WHERE NOT ([4 0 Other] IS NULL) ) AS mySubQuery ORDER BY mySubQuery.[Occurrence Number]; everything was fine until i added the last line: SELECT [Occurrence Number], NULL, NULL,NULL [4 0 Other] FROM [Lab Occurrence Form] WHERE NOT ([4 0 Other] IS NULL) i get this error: syntax error (missing operator) in query expression 'NULL [4 0 Other]' anyone have any clues why i am getting this error?

    Read the article

  • Jointure in linq with a regular expression

    - by Graveen
    I'm actually using a join in linqtosql (via dblinq). I'm trying to include a regular expression in the join part of the linq query. from i in collectiona join j in collectionb on Regex.IsMatch(i.name, j.jokered_name) equals true (...) I agree i can push the RegExp check in the where part of the linq query, but i was wondering if it is possible in the join part ? The above code wants an "i equals j" code structure. One thing i think to perform is overriding Equals() which 'll contains the RegEx.IsMatch() stuff and put a simple i equals j in the join part. Any suggestions about my problem ?

    Read the article

  • One regular expression to match parts in various positions

    - by richsage
    Hi all, I'm trying to parse a DSN (from a Symfony application) using regular expressions, in order to link with a secondary application, but using the same database. The DSN I currently have is: mysql:dbname=my_db_name;host=localhost with a regex of: /^(\w+):(dbname=(\w+))?;?(host=(\w+))?/ (using preg_match()). This matches OK, but fails in my test environment because the DSN elements are switched around, thus: mysql:host=localhost;dbname=my_testdb_name I could just switch them round, yes :-) but I'm sure that extraction of the host and dbname parts from both DSNs is possible with a single regular expression, and I'd like to be able to enhance my knowledge at the same time ;-) Is there a way I can do this?

    Read the article

  • Regular expression match, extracting only wanted segments of string

    - by Ben Carey
    I am trying to extract three segments from a string. As I am not particularly good with regular expressions, I think what I have done could probably be done better... I would like to extract the bold parts of the following string: SOMETEXT: ANYTHING_HERE (Old=ANYTHING_HERE, New=ANYTHING_HERE) Some examples could be: ABC: Some_Field (Old=,New=123) ABC: Some_Field (Old=ABCde,New=1234) ABC: Some_Field (Old=Hello World,New=Bye Bye World) So the above would return the following matches: $matches[0] = 'Some_Field'; $matches[1] = ''; $matches[2] = '123'; So far I have the following code: preg_match_all('/^([a-z]*\:(\s?)+)(.+)(\s?)+\(old=(.+)\,(\s?)+new=(.+)\)/i',$string,$matches); The issue with the above is that it returns a match for each separate segment of the string. I do not know how to ensure the string is the correct format using a regular expression without catching and storing the match if that makes sense? So, my question, if not already clear, how I can retrieve just the segments that I want from the above string?

    Read the article

  • error: polymorphic expression with default arguments

    - by 0__
    This following bugs me: trait Foo[ A ] class Bar[ A ]( set: Set[ Foo[ A ]] = Set.empty ) This yields <console>:8: error: polymorphic expression cannot be instantiated to expected type; found : [A]scala.collection.immutable.Set[A] required: Set[Foo[?]] class Bar[ A ]( set: Set[ Foo[ A ]] = Set.empty ) ^ It is quite annoying that I have to repeat the type parameter in Set.empty. Why does the type inference fail with this default argument? The following works: class Bar[ A ]( set: Set[ Foo[ A ]] = { Set.empty: Set[ Foo[ A ]]}) Please note that this has nothing to do with Set in particular: case class Hallo[ A ]() class Bar[ A ]( hallo: Hallo[ A ] = Hallo.apply ) // nope Strangely not only this works: class Bar[ A ]( hallo: Hallo[ A ] = Hallo.apply[ A ]) ...but also this: class Bar[ A ]( hallo: Hallo[ A ] = Hallo() ) // ???

    Read the article

  • Regular Expression Pattern for C# with matches

    - by Sumit Gupta
    I am working on project where I need to find Frequency from a given text. I wrote a Regular expression that try to detect frequency, however I am stuck with how C# handle it and how exactly I use it in my software My regular experssion is (\d*)(([,\.]?\s*((k|m)?hz)*)|(\s*((k|m)?hz)*))$ And I am trying to find value from 23,2 Hz 24,4Hz 25,0 Hzsadf 26 Hz 27Khz 28hzzhzhzhdhdwe 29 30.4Hz 31.8 Hz 4343.34.234 Khz 65SD Further Explanation: System needs to work for US and Belgium Culture hence, 23.2 (US) = 23,2 (Be) I try to find a Digit, followed by either khz,mhz,hz or space or , or . If it is , or . then it should have another Digit followed by khz, mhz, hz Any help is appericated.

    Read the article

  • Regular Expression - Password Validation is not working

    - by Kesavan
    Hi, I have to validate the password using regex. The password rule is like at least 1 uppercase and at least 2 numeric. It works fine except if the character comes at the end of the string. The regular expression which i am using is "^(?=.*\d.{2})(?=.*[A-Z].{1})(?=.*[@#$%^&+=].{2}).{8,12}$" Rules: minimum length = 8 minimum uppercase = 1 minimum numeric = 2 minimum special character = 1 It works for Test123$$, Test$123, TEST123$s, Test123$1, Test12$3 but it fails if the character specified comes at the end of the string like Test123$, Test$a12, Test12aa@, 123aa@@T. Please let me know if there is any fix for this.

    Read the article

  • Why only the constant expression can be used as case expression in Switch statement?

    - by sinec
    Hi, what is bothering me is that I can't found an info regarding the question from the title. I found that assembly form the Switch-case statement is compiled into bunch of (MS VC 2008 compiler) cmp and je calls: 0041250C mov eax,dword ptr [i] 0041250F mov dword ptr [ebp-100h],eax 00412515 cmp dword ptr [ebp-100h],1 0041251C je wmain+52h (412532h) 0041251E cmp dword ptr [ebp-100h],2 00412525 je wmain+5Bh (41253Bh) 00412527 cmp dword ptr [ebp-100h],3 0041252E je wmain+64h (412544h) 00412530 jmp wmain+6Bh (41254Bh) where for above code will in case that if condition (i) is equal to 2, jump to address 41253Bh and do execution form there (at 41253Bh starts the code for 'case 2:' block) What I don't understand is why in case that,for instance, function is used as 'case expression', why first function couldn't be evaluated and then its result compared with the condition? Am I missing something? Thank you in advance

    Read the article

  • How to use an expression in xsl:include elment in an XSLT processing

    - by addinquy
    I need to include an XSLT that exists in 2 variants, depending on a param value. However, it's seems to be not possible to write an expression in the href attribute of the xsl:include element. My last trial looks like that: < xsl:param name="ml-fmt" select="mono"/ ... < xsl:include href="{$ml-fmt}/format.xsl"/ The XSLT engine used is Saxon 9.2.0.6 Have anybody an idea about how I could do something close to that ?

    Read the article

  • `.' cannot appear in a constant-expression

    - by Amir Rachum
    Hi all, I'm getting the following error: `.' cannot appear in a constant-expression for this function (line 4): bool Covers(const Region<C,V,D>& other) const { const Region& me = *this; for (unsigned d = 0; d < D; d++) { if (me[d].min > other[d].min || me[d].max < other[d].max) { return false; } } can anyone explain the problem please?

    Read the article

  • Regular Expression: Changes HTML Attributes Value to some pattern

    - by brain90
    Dear Engineers, I'm a newbie in RegEx I have thousands html tags, have wrote like this: <input type="text" name="CustomerName" /> <input type="text" name="SalesOrder"/> I need to match every name attribute values and convert them all to be like this: CustomerName -> cust[customer_name] SalesOrder -> cust[sales_order] So the results will be : <input type="text" name="cust[customer_name]" /> <input type="text" name="cust[sales_order]" /> My best try have stuck in this pattern: name=\"[a-zA-Z0-9]*\" - just found name="CustomerName" Please guide me wrote some Regular Expression magics to done this, I'm using Netbeans PDT. Thanks in advance for any pointers!.

    Read the article

  • Regular Expression - Capture and Replace Select Sequences

    - by Chad
    Take the following file... ABCD,1234,http://example.com/mpe.exthttp://example/xyz.ext EFGH,5678,http://example.com/wer.exthttp://example/ljn.ext Note that "ext" is a constant file extension throughout the file. I am looking for an expression to turn that file into something like this... ABCD,1234,http://example.com/mpe.ext ABCD,1234,http://example/xyz.ext EFGH,5678,http://example.com/wer.ext EFGH,5678,http://example/ljn.ext In a nutshell I need to capture everything up to the urls. Then I need to capture each URL and put them on their own line with the leading capture. I am working with sed to do this and I cannot figure out how to make it work correctly. Any ideas?

    Read the article

  • Regular Expression to match unlimited number of options

    - by Pekka
    I want to be able to parse file paths like this one: /var/www/index.(htm|html|php|shtml) into an ordered array: array("htm", "html", "php", "shtml") and then produce a list of alternatives: /var/www/index.htm /var/www/index.html /var/www/index.php /var/www/index.shtml Right now, I have a preg_match statement that can split two alternatives: preg_match_all ("/\(([^)]*)\|([^)]*)\)/", $path_resource, $matches); Could somebody give me a pointer how to extend this to accept an unlimited number of alternatives (at least two)? Just regarding the regular expression, the rest I can deal with. The rule is: The list needs to start with a ( and close with a ) There must be one | in the list (i.e. at least two alternatives) Any other occurrence(s) of ( or ) are to remain untouched.

    Read the article

  • Constructing a regular expression to wrap images with <a>

    - by bobo
    A web page contains lots of image elements: <img src="myImage.gif" width="180" height="18" /> But they may not be very well-formed, for example, the width or height attribute may be missing. And it also may not be properly closed with /. The src attribute is always there. I need a regular expression that wraps these with a hyperlink having href set to the src of the img. <a href="myImage.gif" target="_blank"><img src="myImage.gif" width="180" height="18" /></a> I can successfully locate the images using this regexp in this editor: http://gskinner.com/RegExr/: <img src="([^<]*)"[^<]*> But what is the next step?

    Read the article

  • Using a linq or lambda expression in C# return a collection plus a single value

    - by ahsteele
    I'd like to return a collection plus a single value. Presently I am using a field to create a new list adding a value to the list and then returning the result. Is there a way to do this with a linq or lambda expression? private List<ChargeDetail> _chargeBreakdown = new List<ChargeDetail>(); public ChargeDetail PrimaryChargeDetail { get; set; } public List<ChargeDetail> ChargeBreakdown { get { List<ChargeDetail> result = new List<ChargeDetail>(_chargeBreakdown); result.Add(PrimaryChargeDetail); return result; } }

    Read the article

  • how to write regular expression to validate a string using regex in C#

    - by Charu
    I need to validate a user input based on condition. i wrote a regular expression to do so, but it's failing not sure why. Can somebody point where i am making mistake? Regex AccuracyCodeHexRegex = new Regex(@"^[PTQA]((0|8)[01234567]){2}$"); This is what i am trying to validate(If the string is a subset of these strings then it is valid): Phh, Thh, Qhh, Ahh where 'h' is a hex digit in the set {00, 80, 01, 81, 02, 82, 03, 83, 04, 84, 05, 85, 06, 86, 07, 87} Ex: P00 is valid P20 is not valid

    Read the article

  • NSPredicate aggregate function [SIZE] gives 'unsupported function expression' error

    - by jinglesthula
    iOS 4: I have entities in Core Data (using SQLite, which is a requirement) of: Request Response (which has a property personId) Revision Relationships are: Request <-- Revision Request <-- Response Revision <-- Response (e.g. each request may have many responses; each request/response pair may have many revisions) I'm trying to do a predicate to get all Responses with a given personId that have zero Revisions. Using: (personId == %d) && (Request.Revision[SIZE] == 0) in my predicate string gives me a runtime exception "Unsupported function expression Request.Revision[SIZE]" The documentation seems pretty sparse on aggregate functions, only noting that they exist, but with no syntax or examples. Not sure if it's my syntax or if the SIZE function really isn't supported in iOS.

    Read the article

  • Access: Expression too complex to be evaluated

    - by user2502964
    I'm trying to sort out values from a database by the weekending date. The script I'm using functions on 6 of my 7 databases (they are all constructed identically). The 7th database doesn't function. I get the expression too complex error. any help figuring out why?? Here is my code: SELECT UPC_Test.Type, UPC_Test.[Model No], UPC_Test.[Model Desc], UPC_Test.[Serial No], Format(DateValue([UPC_Test].[Test Date]+7-Weekday([UPC_Test].[Test Date],0)),"m/d/yyyy") AS [Test Date], UPC_Test.Parameter, UPC_Test.[Failure Symptom], UPC_Test.[Repair Action], UPC_Test.[Factory Select], UPC_Test.[Test Station] FROM UPC_Test GROUP BY UPC_Test.Type, UPC_Test.[Model No], UPC_Test.[Model Desc], UPC_Test.[Serial No], Format(DateValue([UPC_Test].[Test Date]+7-Weekday([UPC_Test].[Test Date],0)),"m/d/yyyy"), UPC_Test.Parameter, UPC_Test.[Failure Symptom], UPC_Test.[Repair Action], UPC_Test.[Factory Select], UPC_Test.[Test Station] HAVING (((UPC_Test.Type)="Production") AND ((Format(DateValue([UPC_Test].[Test Date]+7-Weekday([UPC_Test].[Test Date],0)),"m/d/yyyy"))=[Enter]) AND ((UPC_Test.[Failure Symptom])<>"") AND ((UPC_Test.[Repair Action])<>"") AND ((UPC_Test.[Test Station])="UPC RF Test")) ORDER BY Format(DateValue([UPC_Test].[Test Date]+7-Weekday([UPC_Test].[Test Date],0)),"m/d/yyyy");

    Read the article

  • Django - Expression based model constraints

    - by rtmie
    Is it possible to set an expression based constraint on a django model object, e.g. If I want to impose a constraint where an owner can have only one widget of a given type that is not in an expired state, but can have as many others as long as they are expired. Obviously I can do this by overriding the save method, but I am wondering if it can be done by setting constraints, e.g. some derivative of the unique_together constraint WIDGET_STATE_CHOICES = ( ('NEW', 'NEW'), ('ACTIVE', 'ACTIVE'), ('EXPIRED', 'EXPIRED') ) class MyWidget(models.Model): owner = models.CharField(max_length=64) widget_type = models.CharField(max_length = 10) widget_state = models.CharField(max_length = 10, choices = WIDGET_STATE_CHOICES) #I'd like to be able to do something like class Meta: unique_together = (("owner","widget_type","widget_state" != 'EXPIRED')

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >