Questions tagged [wildcard]

A wildcard character is a specially defined character allowing for substitution of any other character, including a pattern or sequence of characters. Use this tag for questions on how to use wildcards for regular expressions, shell scripting, string manipulation and database control, but not for use in terminal commands as that is off-topic.

A wildcard character is a special character defined by many different systems/programming languages with each their own specific implementations. They may allow for accessing single characters, sets of characters or all characters matching a certain regex pattern.

Examples include :

* - Any sequence of characters. (DOS/Unix)
? - Any single character. (DOS/Unix)
% - Zero or more characters. (SQL)
# - Matches a single numeral. (SQL)
. - Matches a single character. (Regular Expressions)

4611 questions
17
votes
10 answers

Java Generics WildCard Question: List

Let's say I have these classes : Vehicle, Car and Spaceship: class Vehicle{ void rideVehicle(Vehicle v){ System.out.println("I am riding a vehicle!"); } } class Car extends Vehicle{ void rideVehicle(Vehicle c){ …
Saher Ahwal
  • 9,015
  • 32
  • 84
  • 152
17
votes
2 answers

How to skip the for loop when there are no matching files?

When I loop through all the files starting by foo I do for f in foo* ; do echo "result = $f" ; done The problem is when no file start by foo I get: result = foo* Meaning that the loop is executed once, even if no file start by foo. How is this…
Jav
  • 1,445
  • 1
  • 18
  • 47
17
votes
4 answers

Optimization of MySQL search using "like" and wildcards

How can queries like SELECT * FROM sometable WHERE somefield LIKE '%value%' be optimized? The main issue here is the first wildcard which prevents DBMS from using index. Edit: What is more, somefield value is solid string (not a piece of text) so…
Jonas
  • 2,910
  • 2
  • 26
  • 36
17
votes
4 answers

Regular expression wildcard

I've just started using Regular Expressions and this is so overwhelming that even after reading documentation I can't seem to find where to start to help with my problem. I have to a bunch of strings. "Project1 - Notepad" "Project2 - Notepad" …
phadaphunk
  • 12,785
  • 15
  • 73
  • 107
17
votes
2 answers

Using two asterisks to add a file in git

I want to add a file which has a unique file name but a long preceding path (e.g. a/b/c/d/filename.java). Normally I would add this to my repository by doing git add *filename.java. However I have also done this before: git add a/b/c/d/filename* So…
Paul
  • 1,341
  • 5
  • 15
  • 29
16
votes
3 answers

Broken wildcard expansion for Java7 commandline on Windows(7?)

I observe a strange behavior of wildcard expansion behavior for Java7 on Windows. For centuries there was a clean difference between "*" versus *. Seems this it not longer true for Java7 (at least on Windows7). I noticed the problem when using a…
Ditz
  • 735
  • 7
  • 17
16
votes
1 answer

Java Wildcard-types vs Kotlin Star-projection

I was reading a kotlin documentation about differences between Java and Kotlin here https://kotlinlang.org/docs/reference/comparison-to-java.html. It was stated there that Kotlin does not have wildcard-types. However after reading carefully through…
pokemzok
  • 1,659
  • 1
  • 19
  • 29
16
votes
3 answers

Find whitespace in end of string using wildcards or regex

I have a Resoure.resx file that I need to search to find strings ending with a whitespace. I have noticed that in Visual Web Developer I can search using both regex and wildcards but I can not figure out how to find only strings with whitespace in…
Martin
  • 219
  • 1
  • 5
  • 10
16
votes
4 answers

Why can't I use the wildcard (?) as type of parameter, field, local variable, or as return type of a method?

The Oracle doc about Wildcards in generics says, The wildcard can be used in a variety of situations: as the type of a parameter, field, or local variable; sometimes as a return type (though it is better programming practice to be more…
Solace
  • 8,612
  • 22
  • 95
  • 183
16
votes
1 answer

Capture conversion issue in Java, WRT reconciliation of JLS and actual JDK behaviour

Given the following two class definitions: class C1> {} class C2 extends C1> {} Consider the following type declaration: C1> c; This compiles fine in JDK-8u45, but if we examine the specification for…
Elias Vasylenko
  • 1,524
  • 11
  • 21
16
votes
4 answers

Why use a wild card capture helper method?

Referring to : Wildcard Capture Helper Methods It says to create a helper method to capture the wild card. public void foo(List i) { fooHelper(i); } private void fooHelper(List l) { l.set(0, l.get(0)); } Just using this…
Brandon Ling
  • 3,841
  • 6
  • 34
  • 49
16
votes
5 answers

Casting generics list in Java

I found a weird situation when casting generics. I run this code: class A { } class B { } public class Program { @SuppressWarnings("unchecked") public static void main(String[] args) { List listA = new ArrayList(); …
nrofis
  • 8,975
  • 14
  • 58
  • 113
16
votes
2 answers

GNU Makefile: multiple outputs from single rule + preventing intermediate files from being deleted

This is sort of a continuation of question from here. The problem is that there is a rule generating multiple outputs from a single input, and the command is time-consuming so we would prefer to avoid recomputation. Now there is an additional twist,…
makesaurus
  • 1,393
  • 3
  • 10
  • 7
16
votes
6 answers

Full text catalog/index search for %book%

I'm trying to wrap my head around how to search for something that appears in the middle of a word / expression - something like searching for "LIKE %book% " - but in SQL Server (2005) full text catalog. How can I do that? It almost appears as if…
Marc
16
votes
3 answers

Exclude a string from wildcard search in a shell

I am trying to exclude a certain string from a file search. Suppose I have a list of files: file_Michael.txt, file_Thomas.txt, file_Anne.txt. I want to be able and write something like ls *.txt to give me file_Michael.txt and…
steigers
  • 201
  • 2
  • 3
  • 6