w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Java pattern expression to exclude a special string
I'm not sure about a single regex solution, but you can achieve the same in a 2-fold approach : public static String parsePath(String content, String regex) { content = content.replaceFirst("^url\:\(["']?([.]{2})?(/[.]{2})*", ""); // rest is same as previous // ....................... } Then use the following in Matcher : regex = "(^([a-z]+)?(/?[a-z]+)*)(?=["']?\)$)" You may put the regex inside method itself, rather than passing it as a parameter. And update the character class([a-z]) as per your need. NOTE : The above solution won't match strings like "url:("../..../aaa/bbb/ccc")" or "url:("..../../aaa/bbb/ccc")" or "url:("..///")" at all, which was not handled by the regex you show in the question and comment.

Categories : Java

How to exclude a specific string/pattern from a regular expression in oracle?
try to replace the string you want to exclude with a string that would not be found by your regexp. e.g with str as ( select '1013;' as s from dual union select '1013' from dual union select '1013:' from dual union select '10133;' from dual ) select s , regexp_substr(s, '1([^34][:;]|[0-9][^:;].*)') --> regexp , regexp_replace(s,'^1013($|:|;)','x') --> replaced string , regexp_substr(regexp_replace(s,'^1013($|:|;)','x') , '1([^34][:;]|[0-9][^:;].*)') --> regexp with replaced string from str ;

Categories : Regex

Regular Expression - Match But Exclude?
Here's an easy way: string sampleText = "<i>This should be in italics</i> but this ¶ character needs to be removed"; string sPattern = "(</?i>)|[―&<>♫♪–‧₢₳-⅓⅟□¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕ×ØÙÚÛÜÝÞßàáãäåæçèéêëìíîïðñòóôö÷øùüýþÿŒœŠšŸŽžƒ˜-‰›¢€°]"; string replacePattern = "$1"; string text = Regex.Replace(sampleText, sPattern, replacePattern, RegexOptions.IgnoreCase); Console.WriteLine(text); // <i>This should be in italics</i> but this character needs to be removed But this will only work with <i> and </i> tags. You can expand that to other tags pretty easily (e.g. "(</?w+>)|..."

Categories : C#

Regular Expression to exclude files
I think this should work: [a-zA-Z][S]*^(ABC|XYZ) but Im not 100% sure of all the details of your requirements. What the regex should be saying is anything that starts with an alphabetic letter and then has as many non-white space characters as it wants and then does NOT end in ABC or XYZ.

Categories : Regex

Reflection to call generic method with lambda expression parameter
You can solve your problem by using the following set of classes. First, we need to create a Contains class which will decide which items will be chosen from the source array. class Contains { public bool Value { get; set; } public Contains(object[] items, object item) { Value = (bool)(typeof(Enumerable).GetMethods() .Where(x => x.Name.Contains("Contains")) .First() .MakeGenericMethod(typeof(object)) .Invoke(items, new object[] { items, item })); } } Then we need to create a Where class which will be used to form a predicate based on which items will be selected. It should be clear that in our cas

Categories : C#

Invoke a method using reflection by passing an Expression>
The problem is that Expression<T> is invariant, so even if you have a type T which can be assigned to type U, that doesn't mean that Expression<T> can be assigned to Expression<U>. In your case, T is Func<CLI, IList<Grouping>> and U is Func<CLLI, object>. I think the only solution is to create a function to wrap a given expression in an Expression<Func<T, object>> which delegates to the inner expression and casts the result to object: public static Expression<Func<T, object>> ConvertResult<T, TOut>(Expression<Func<T, TOut>> expr) { var paramExpr = Expression.Parameter(typeof(T)); var invokeExpr = Expression.Invoke(expr, paramExpr); var castExpr = Expression.Convert(invokeExpr, typeof(object));

Categories : C#

Exclude elements from vector based on regular expression pattern
Edit: From the comments, and with a little testing, one would find that my suggestion wasn't correct. Here are two correct solutions: vector[!grepl("['pyfgcrl]", vector)] ## kohske grep("['pyfgcrl]", vector, value = TRUE, invert = TRUE) ## flodel If either of them wants to re-post and accept credit for their answer, I'm more than happy to delete mine here. Explanation The general function that you are looking for is grepl. From the help file for grepl: grepl returns a logical vector (match or not for each element of x). Additionally, you should read the help page for regex which describes what character classes are. In this case, you create a character class ['pyfgcrl], which says to look for any character in the square brackets. You can then negate this wi

Categories : Regex

Trying to fill a List> with reflection is always empty
Try to add BindingFlags.Instance to the binding flags filter: BindingFlags.Public | BindingFlags.Instance. More on binding flags can be found here.

Categories : C#

The WHERE clause function expects a tuple set expression for the argument. A string or numeric expression was used
you can use what is recommended here. Here is how your code should look like: SELECT Measures.[Internet Sales Amount] ON COLUMNS,filter( ({Product.[Product Line].[Product Line].MEMBERS} * {[Customer].[Country].MEMBERS}), Measures.[Internet Sales Amount] > 2000000) on ROWS FROM [Adventure Works]

Categories : Sql Server

The Axis0 function expects a tuple set expression for the argument. A string or numeric expression was used
An axis expression must contain a set of tuples that are defining the shape of the result; you are using a value instead. You should use a calculated measure as following : with member [Measures].[Profit] as [Measures].[Internet Sales Amount] - [Measures].[Internet Standard Product Cost] SELECT [Measures].[Profit] ON COLUMNS, [Customer].[Country].MEMBERS ON ROWS FROM [Adventure Works] Have a look to this page for a gentle introduction to MDX select statement.

Categories : Sql Server

Get value of String variable via reflection
You need to call: Object val = f.get(this); OR to get String object: String strval = (String) f.get(this); to get field represented by f's value. See: Field#Get(Object) Also: Getting and Setting Field Values

Categories : Java

create object with reflection - from string
Method newInstance takes varargs (AnyRef*), not Array[Any]. You are trying to call constructor with 1 argument - Array. You should convert Array[Any] to Array[AnyRef] and than call method with special syntax : _*: constructor.newInstance(convertedArguments.map{_.asInstanceOf[AnyRef]}: _*)

Categories : Scala

init string constants by reflection
You can replace these constants by an enum and still keep the advantages you've listed: public enum Tags { PROXY("proxy"), NAME("name"), X("x"), Y("y"); public final String value; private Tags(String value) { this.value = value; if (!value.equals(name().toLowerCase())) { throw new RuntimeException("Value and name do not match"); } } public static void main(String[] args) { for (Tags tag : Tags.values()) { System.out.println(tag + " " + tag.value); } } } In the code above, the test value.equals(name().toLowerCase()) is not necessary but you seem concerned about mistyping errors

Categories : Java

How to get string value from a Java field via reflection?
It looks like you need a reference to an instance of the class. You would want to call get and pass in the reference, casting the return to a String. You can use get as follows: String strValue = (String) field.get (objectReference);

Categories : Java

How to get value of String field from Java reflection?
Easiest way is to use BeanUtils: String s = BeanUtils.getProperty(someObj, "strField"); Note that BeanUtils will attempt to convert your property into string. You need to have a getter and setter of the property

Categories : Java

Reflection - creating datatype from a string literal value
You can use Type.GetType together with Activator.CreateInstance: Public Function getVariable(ByVal strDataType As String) Return Activator.CreateInstance(Type.GetType(strDataType)) End Function For strDataType you need to be using System.Int32, System.Decimal and System.Double respectively. If you want to keep it as Integer etc., you need to incorporate string translation, for example, have a Dictionary(Of String, String), with entries like ("Integer", "System.Int32").

Categories : Vb.Net

Javascript reflection, call a method with a string
Use bracket notation instead of dot notation: orderdet[strMethod]();

Categories : Javascript

Call a method with String[] parameter using reflection
The method my_method() receives as a parameter a String[], not a String. You're calling a different method. The code should look like this: paramString[0] = String[].class; Method method = cls.getDeclaredMethod("my_method", paramString); To invoke it, pass a String[] as parameter: method.invoke(obj, new String[]{"x"}); Also, the body of the loop in my_method() should refer to each element's position, not to the array itself: System.out.println(args[i]);

Categories : Java

Find all string values from complex object using Reflection
Any lists, any array -> any IEnumerable. So you can replace: if (type.IsArray) To: if (typeof(IEnumerable).IsAssignableFrom(type)) To prevent StackOverflowException just don't visit visited objects. Do you like idea? So, firstly we must choose: we don't want visit all visited objects or only parent objects. In this case, we won't visit all visited objects. So, modifcate header: // visitedObjects can changes private static IEnumerable<string> _FindStringValues(object obj, IList<object> visitedObjects) Now, modificate all calls of FindStringValues to call of _FindStringValues in this method: _FindStringValues(item, visitedObjects) And add usable wrapper-method: private static IEnumerable<string> FindStringValues(object obj) { return _FindStringValues(obj, n

Categories : C#

find a string with _id and exclude a value
Add a negative lookahead: /^(?!author_id$)(w+)_id$/ > "foo_id".match(/^(?!author_id$)(w+)_id$/) ["foo_id", "foo"] > "author_id".match(/^(?!author_id$)(w+)_id$/) null

Categories : Javascript

converting Object returned by Field.get() to String[] in java reflection
The Object that you get from the call of arrayf.get(inst) is of type Object[], not String[], because Java generics are implemented through type erasure. You can do this: Object[] strings = (Object[])arrayf.get(inst); System.out.println(strings.length); for (int i = 0 ; i != strings.length ; i++) { String s = (String)strings[i]; ... } P.S. I am going to stay away from the discussion on whether it's a good idea to unit test the private details of the implementation.

Categories : Java

Need help in Regex to exclude splitting string within "
Please try this: (?<!Gs*"[^"]*), If you put this regex in your program, it should be: String regex = "(?<!\G\s*"[^"]*),"; But 2 things are not clear: Does the " only start near the ,, or it can start in the middle of content, such as AAA, BB"CC,DD" ? The regex above only deal with start neer , . If the content has " itself, how to escape? use "" or "? The regex above does not deal any escaped " format.

Categories : Java

Exclude a certain String from variable in regex
It seems XSLT regex does not support look-around. So I don't think you'll be able to get a solution for this that does not involve writing out all strings from journal_abbrevs in your regex. Related question. To minimize the amount of writing out, you could split journal_abbrevs into say journal_abbrevs1, journal_abbrevs2 and journal_abbrevs3 (or how many you decide to use) and only write out whichever one that contains the string you wish to exclude. If journal_abbrevs1 contains the string, you'd then end up with something like: ((&journal_abbrevs2;)|(&journal_abbrevs3;)|example-String2|example-String3|...)... If it supported look-around, you could've used a very simple: (?!example-String1)(&journal_abbrevs;)...

Categories : Regex

How to exclude a row based on a partial string match?
How about: . . . WHERE keywords LIKE '%portraits%' AND keywords NOT LIKE '%outdoors%' . . . A better approach might be to define a separate table of keywords for jobs. It would have one row for each job/keyword combination. With proper indexing, you can greatly speed up the lookup of jobs with or without matching keywords.

Categories : Mysql

Safely using String for passwords by using reflection to scrub contents prior to garbage collection
One argument I have against String is that it's just too easy to inadvertently make a copy. Using strings safely is possible in theory, but the whole library ecosystem is based on the assumption that it's perfectly OK to copy strings. In the end, considering all the restrictions, strings may not be as convenient for this use case as they generally are.

Categories : Java

Exclude UICulture string (ex: en-US) from URL generated by UrlHelper.Action?
Check your routes definition. Probably you have a rule with an attribute like {culture}. You can delete that attribute or, if you need it in other sections of your application, you can add another route definition without the culture and, in place of Url.Action, you can use Url.RouteUrl (giving, as a parameter, the name of the route definition).

Categories : C#

LinqPad Error: Lambda expression cannot be converted to 'String' because 'String' is not a delegate type
The problem appears to be that one or more of the properties of object "p" is not a string. However, you most likely are misunderstanding what .Include does. It eager-loads whichever related tables you specify. So if you had: Dim projects = From p In db.Projects.Include("Managers") it would eager-load all of the related records from your "Managers" table for each row in your "Projects" table when the query is executed. Somehow, I don't think this is what you are trying to accomplish with the code you posted.

Categories : Vb.Net

exclude a particular directory and exclude a list of files
File#listFiles takes a FileFilter which can be used to determine if certain files should be included or not in the listing returne by File#listFiles... This is okay if you know in advance what you to to include/exclude. If you want to make the process more dynamic, you could pass a list of FileFilters to the copy method and then use a special FileFilter to iterate over them... private void copyFiles(File src, File tgt, FileFilter... filters) { /*...*/ File[] filePaths = src.listFiles(new GroupedFileFiler(filters)); /*...*/ } public class GroupedFileFilter implements FileFilter { private FileFilter[] filters; public GroupedFileFilter(FileFilter... filters) { this.filters = filters; } @Override public boolean accept(File pathname) { boo

Categories : Java

Compare the string with other string using regular expression in oracle
Select 'Y' from dual where regexp_like('test|xyz|test1|xyz1','xyz','i'); It will return result only for matched values. If you want 'n' for unmatched values then try regular expression instring. Or you can do it simply with lower() function on both side and checking for instring. select case when regexp_instr('test|xyz|test1|xyz1','XYz',1,1,1,'i') > 0 then 'y' else 'n' end col1 from dual

Categories : SQL

Cast ArrayList to String[] in one expression?
Try this: super(s.toArray(new String[s.size()])); The above is the type-safe way to convert an ArrayList into an array, it's not a really cast, just a conversion. Regarding the new error reported - you have to declare a no-arg constructor in the entity mentioned in the error.

Categories : Java

iOS string expression to integer value
NSString *string = @"1+2+3232+4"; NSArray *array = [string componentsSeparatedByString:@"+"]; NSInteger result = 0; for (NSString *value in array) result += [value integerValue]; NSLog(@"%i", result);

Categories : IOS

EDU String to Regular Expression
I would implement two validations: check for correct email format validates :email, :format => { :with => /A([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})/i, :on => :create } check for .edu domains validates :email, :format => { :with => /.edu/i, :on => :create }

Categories : Ruby On Rails

expression expected '{' - having string and int together
DataTable.Rows.Add method requires an array of objects (one object for each column) so your code could be simply table2.Rows.Add (row(0), row(1)) By the way, if you are trying to copy from one table to another take a look at the built-in methods DataTable.Merge or DataTable.Copy as well DataTable.LoadDataRow and DataTable.ImportRow

Categories : Dotnet

Get string with PHP regular Expression
Quick & Dirty: #w+ #b+ d+(?:.?d+)? (.*) Example: <?php $string = "France Gros Frère et Sur Hte-Cote de Nuit Blc 2008 #wwww #bbbbb 8.5 Nice yellow fruit nose, some vanilla notes, good crispness"; $regex = "/#w+ #b+ d+(?:.?d+)? (.*)/"; preg_match ($regex, $string, $output); echo $output[1]; ?> But if there can be a string WITHOUT any number after #bbbbb, you better use this: #w+ #b+s*(?:d+(?:.d+)?)?s*(.*) So you don't have to put any number after #bbbbb and you can use as many spaces as you like between #bbbbb, the number (if there's any) and the string you want to extract. Most of it is optional, so your string could look like this: blabla #w #bb Hello World Or like this blabla #wwwwwwwwwwwwwwww #bbb 1337 Hello World Or like this: #w #bHello World

Categories : PHP

evaluate EL expression within String value
You can use Application#evaluateExpressionGet() to evaluate a string as an EL expression and get the outcome. FacesContext context = FacesContext.getCurrentInstance(); Object result = context.getApplication().evaluateExpressionGet(context, nameEL, Object.class); // ... In OmniFaces, this is also available in Faces class. Object result = Faces.evaluateExpressionGet(nameEL); // ...

Categories : JSF

Searching string with sql contains and building "contains" expression with ASP.Net
You can build by using a functions that accepts your search term and then splits and joins that to give your desired Contains argument. public string ContainsBuilder(string searchterm) { var sb = new StringBuilder(); sb.Append('"'); sb.Append(searchterm); sb.Append('"'); sb.Append(" OR ("); sb.Append(String.Join(" OR ",searchterm.Split(' '))); sb.Append(")"); return sb.ToString(); } if you call this method with paris restaurants it returns "paris restaurants" OR (paris OR restaurants)

Categories : Asp Net

Simple string regular expression
if you go to http://gskinner.com/RegExr/ you can write this expression: ^(C0[0-9]*[0-9]{4})[^0-9] And in the content you put: C012345 - legal C047851 - legal C*1*54821 - not legal (does not starts with 'C0') C0412 - not legal (mismatch length) C0*a*4587 - not legal And you will see that it only matches what you want.

Categories : C#

Alphanumeric Regular Expression String
I think you will have to escape the +, and the metacharacter after [BC] needs to be * for "zero or more" instead of + for one or more. You also don't need the ? at the end since there's no need to make this a non-greedy match; you're matching till the end of the string anyway: /^+?d+[BC]*$/ Otherwise, what you have is not really a valid regex. There is nothing to repeat for the + at the beginning, and the ^ is just an anchor for the beginning of the string.

Categories : Regex

mysql if statement with string expression
Your @pr_ans isn't actually evaluated, you're just getting a truthy response because the string isn't NULL. You probably want something like EXECUTE instead. How about using the following instead: mysql> SET @pr_ans = 'SELECT (? > 22.5 AND ? < 27.5) AS result'; mysql> PREPARE stmt1 FROM @pr_ans; mysql> SET @pr_mine = 2; mysql> EXECUTE stmt1 USING @pr_mine, @pr_mine; +--------+ | result | +--------+ | 0 | +--------+ mysql> SET @pr_mine = 25; mysql> EXECUTE stmt1 USING @pr_mine, @pr_mine; +--------+ | result | +--------+ | 1 | +--------+ mysql> DEALLOCATE PREPARE stmt1; Which would give you 0 or 1 for false/true. You could keep use REPLACE if you so chose, but you're better off using a prepared statement.

Categories : Mysql

Split string using regular expression in php
you can split them if they are always like this vith substr() function reference: http://php.net/manual/en/function.substr.php but if they are dynamic in lenght. you need to get a ; or any other sign that is not likely to be used there before 2nd "http://" and then use explode function reference: http://php.net/manual/en/function.explode.php $string = "http://something.com/;http://something2.com"; $a = explode(";",$string);

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.