当前位置: 首页 > 编程日记 > 正文

java正则表达式课程_通过此免费课程学习正则表达式

java正则表达式课程

by Beau Carnes

通过博卡恩斯

通过此免费课程学习正则表达式 (Learn Regular Expressions with this free course)

“Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems.” -Jamie Zawinski

“有些人遇到问题时会想,'我知道,我会使用正则表达式。' 现在他们有两个问题。” -贾米·扎温斯基

For some people, using regular expressions can be a problem. But it doesn’t have to be a problem for you. This article is a full course on Regular Expressions.

对于某些人来说,使用正则表达式可能会成为一个问题。 但这对您来说不一定是问题。 本文是有关正则表达式的完整课程。

1.简介 (1. Introduction)

Regular Expressions, or just RegEx, are used in almost all programming languages to define a search pattern that can be used to search for things in a string.

几乎所有编程语言都使用正则表达式(或称RegEx)来定义可用于搜索字符串中的内容的搜索模式。

I’ve developed a free, full video course on Scrimba.com to teach the basics of regular expressions.

我在Scrimba.com上开发了一个免费的完整视频课程 ,以教授正则表达式的基础知识。

This article contains the course in written form. But if you would prefer to watch the video version with interactive lessons, you can check it out on Scrimba. The sections in this article correspond to the sections in the Scimba course.

本文包含书面形式的课程。 但是,如果您希望通过互动课程观看视频版本,可以在Scrimba上查看 。 本文中的各个部分与Scimba课程中的各个部分相对应。

This course follows along with the RegEx curriculum at freeCodeCamp.org. You can check that out for coding challenges and to earn a certificate.

本课程与freeCodeCamp.org上的RegEx课程一起进行。 您可以检查出编码挑战并获得证书。

These lessons focus on using RegEx in JavaScript, but the principles apply in many other programming languages you might choose to use. If you don’t already know basic JavaScript, it could be helpful if you cover it a bit first. I also have a basic JavaScript course that you can access on Scrimba and on the freeCodeCamp.org YouTube channel.

这些课程侧重于在JavaScript中使用RegEx,但是这些原理适用于您可能选择使用的许多其他编程语言。 如果您还不了解基本JavaScript,那么如果您稍稍介绍一下它会很有帮助。 我也有一个基本JavaScript课程,您可以在Scrimba和freeCodeCamp.org YouTube频道上进行访问 。

So let’s get started! You’ll be saving the day in no time. ?

因此,让我们开始吧! 您将立即节省一天的时间。 ?

2.使用测试方法 (2. Using the Test Method)

To match parts of strings using RegEx, we need to create patterns that help you to do that matching. We can indicate that something is a RegEx pattern by putting the pattern between slashes /, like so /pattern-we-want-to-match/.

要使用RegEx匹配字符串的各个部分,我们需要创建模式来帮助您进行匹配。 我们可以通过将模式放在斜线/之间来表明某种东西是RegEx模式,例如/pattern-we-want-to-match/

Let’s look at an example:

让我们看一个例子:

// We want to check the following sentencelet sentence = "The dog chased the cat."
// and this is the pattern we want to match.let regex = /the/

Notice how we use /the/ to indicate that we are looking for “the” in our sentence.

注意我们如何使用/the/来指示我们在sentence中寻找“ the”。

We can use RegEx test() method to tell if a pattern is present in a string or not.

我们可以使用RegEx test()方法来判断字符串中是否存在模式。

// String we want to testlet myString = "Hello, World!";
// Pattern we want to findlet myRegex = /Hello/;
// result is now truelet result = myRegex.test(myString);

3.匹配文字字符串 (3. Match Literal Strings)

Let’s now find Waldo.

现在让我们找到Waldo。

let waldoIsHiding = "Somewhere Waldo is hiding in this text.";let waldoRegex = /Waldo/;
// test() returns true, so result is now also truelet result = waldoRegex.test(waldoIsHiding);

Note that in this example waldoRegex is case sensitive, so if we were to write /waldo/ with a lowercase ‘w’, then our result would be false.

请注意,在此示例中, waldoRegex区分大小写,因此,如果我们用小写的“ w”编写/waldo/ ,则result将为false。

4.匹配具有不同可能性的文字字符串 (4. Match a Literal String with Different Possibilities)

RegEx also has OR operator which is | character.

RegEx还具有OR运算符,该OR符为| 字符。

let petString = "James has a pet cat.";
// We can now try to find if either of the words are in the sentencelet petRegex = /dog|cat|bird|fish/;
let result = petRegex.test(petString);

5.匹配时忽略大小写 (5. Ignore Case While Matching)

So far, we have looked at patterns when the case of the letters mattered. How can we make our RegEx patterns to be case insensitive?

到目前为止,我们已经研究了字母大小写重要时的模式。 我们如何使RegEx模式不区分大小写?

To ignore case we can do it by adding the i flag at the end of a pattern, like so /some-pattern/i.

要忽略大小写,我们可以通过在模式末尾添加i标志来实现,例如/some-pattern/i

let myString = "freeCodeCamp";
// We ignore case by using 'i' flaglet fccRegex = /freecodecamp/i;
// result is truelet result = fccRegex.test(myString);

6.提取比赛 (6. Extract Matches)

When we want to extract the matched value we can use match() method.

当我们要提取匹配的值时,可以使用match()方法。

let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /coding/;
let result = extractStr.match(codingRegex);
console.log(result);
// Terminal will show: // > ["coding"]

7.比首场比赛多 (7. Find More Than the First Match)

Now when we know how to extract one value and it’s also possible to extract multiple values using theg flag

现在,当我们知道如何提取一个值并且还可以使用g标志提取多个值时

let testStr = "Repeat, Repeat, Repeat";
let ourRegex = /Repeat/g;
testStr.match(ourRegex); // returns ["Repeat", "Repeat", "Repeat"]

We can also combine theg flag with thei flag, to extract multiple matches and ignore casing.

我们还可以将g标志与i标志结合使用,以提取多个匹配项并忽略大小写。

let twinkleStar = "Twinkle, twinkle, little star";
let starRegex = /twinkle/ig;// writing /twinkle/gi would have the same result.
let result = twinkleStar.match(starRegex);
console.log(result);
// Terminal will show: // > ["Twinkle", "twinkle"]

8.用通配符匹配任何内容 (8. Match Anything with Wildcard Period)

In RegEx . is a wildcard character that would match anything.

在RegEx中. 是可以匹配任何内容的通配符。

let humStr = "I'll hum a song";
let hugStr = "Bear hug";
// Looks for anything with 3 characters beginning with 'hu'let huRegex = /hu./;
humStr.match(huRegex); // Returns ["hum"]
hugStr.match(huRegex); // Returns ["hug"]

9.将单个字符与多个可能性匹配 (9. Match Single Character with Multiple Possibilities)

Matching any character is nice, but what if we want to restrict the matching to a predefined set of characters? We can do by using [] inside our RegEx.

匹配任何字符都很好,但是如果我们想将匹配限制为预定义的字符集怎么办? 我们可以通过在RegEx中使用[]来实现。

If we have /b[aiu]g/, it means that we can match ‘bag’, ‘big’ and ‘bug’.

如果我们有/b[aiu]g/ ,则意味着我们可以匹配“ bag”,“ big”和“ bug”。

If we want to extract all the vowels from a sentence, this is how we can do it using RegEx.

如果我们想从一个句子中提取所有元音,这就是我们使用RegEx做到的方式。

let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /[aeiou]/ig;
let result = quoteSample.match(vowelRegex);

10.匹配字母 (10. Match Letters of the Alphabet)

But what if we want to match a range of letters? Sure, let’s do that.

但是,如果我们要匹配一系列字母怎么办? 当然,让我们这样做。

let quoteSample = "The quick brown fox jumps over the lazy dog.";
// We can match all the letters from 'a' to 'z', ignoring casing. let alphabetRegex = /[a-z]/ig;
let result = quoteSample.match(alphabetRegex);

11.匹配数字和字母 (11. Match Numbers and Letters of the Alphabet)

Letters are good, but what if we also want numbers?

字母很好,但是如果我们也想要数字怎么办?

let quoteSample = "Blueberry 3.141592653s are delicious.";
// match numbers between 2 and 6 (both inclusive), // and letters between 'h' and 's'. let myRegex = /[2-6h-s]/ig;
let result = quoteSample.match(myRegex);

12.匹配未指定的单个字符 (12. Match Single Characters Not Specified)

Sometimes it’s easier to specify characters that you don’t want to watch. These are called ‘Negated Characters’ and in RegEx you can do it by using ^.

有时,指定不想观看的字符会更容易。 这些被称为“否定字符”,在RegEx中,您可以使用^

let quoteSample = "3 blind mice.";
// Match everything that is not a number or a vowel. let myRegex = /[^0-9aeiou]/ig;
let result = quoteSample.match(myRegex);// Returns [" ", "b", "l", "n", "d", " ", "m", "c", "."]

13.匹配字符出现一次或多次 (13. Match Characters that Occur One or More Times)

If you want to match a characters that occurs one or more times, you can use +.

如果要匹配出现一次或多次的字符,可以使用+

let difficultSpelling = "Mississippi";
let myRegex = /s+/g;
let result = difficultSpelling.match(myRegex);// Returns ["ss", "ss"]

14.出现零次或多次的匹配字符 (14. Match Characters that Occur Zero or More Times)

There is also a * RegEx quantifier. This one matches even 0 occurrences of a character. Why might this be useful? Most of the time it’s usually in combination with other characters. Let’s look at an example.

还有一个* RegEx量词。 这一个与0个字符匹配。 为什么这可能有用? 在大多数情况下,它通常与其他字符结合使用。 让我们来看一个例子。

let soccerWord = "gooooooooal!";
let gPhrase = "gut feeling";
let oPhrase = "over the moon";
// We are trying to match 'g', 'go', 'goo', 'gooo' and so on. let goRegex = /go*/;
soccerWord.match(goRegex); // Returns ["goooooooo"]
gPhrase.match(goRegex); // Returns ["g"]
oPhrase.match(goRegex); // Returns null

15.通过延迟匹配查找字符 (15. Find Characters with Lazy Matching)

Sometimes your pattern matches can have more than one outcome. For example, let’s say I’m looking for a pattern in a word titanic and my matched values must begin with a ‘t’ and end with an ‘i’. My possible results are ‘titani’ and ‘ti’.

有时,您的模式匹配可以有多个结果。 例如,假设我正在寻找titanic单词中的模式,并且我匹配的值必须以“ t”开头,以“ i”结尾。 我可能的结果是“ titani”和“ ti”。

This is why RegEx has a concepts of ‘Greedy Match’ and ‘Lazy Match’.

这就是RegEx具有“贪婪匹配”和“惰性匹配”概念的原因。

Greedy match finds the longest possible match of the string that fits the RegEx pattern, this is a default RegEx match:

贪婪匹配查找字符串适合的正则表达式,这是一个默认的正则表达式匹配 最长可能的匹配

let string = "titanic";
let regex = /t[a-z]*i/;
string.match(regex);// Returns ["titani"]

Lazy match finds the shortest possible match of the string that fits the RegEx pattern and to use it we need to use ?:

惰性匹配找到适合RegEx模式的字符串 最短匹配 ,要使用它,我们需要使用?

let string = "titanic";
let regex = /t[a-z]*?i/;
string.match(regex);// Returns ["ti"]

16.寻找一个或多个罪犯 (16. Find One or More Criminals in a Hunt)

Now let’s have a look at a RegEx challenge. We need to find all the criminals (‘C’) in a crowd. We know that they always stay together and you need to need to write a RegEx that would find them.

现在让我们来看看RegEx挑战。 我们需要在人群中找到所有罪犯('C')。 我们知道它们始终在一起,您需要编写一个RegEx来查找它们。

let crowd = 'P1P2P3P4P5P6CCCP7P8P9';
let reCriminals = /./; // Change this line
let matchedCriminals = crowd.match(reCriminals);

You can find me walking through the solution in this Scrimba cast.

您可以在这个Scrimba演员表中找到我在解决方案中的操作 。

17.匹配开始字符串模式 (17. Match Beginning String Patterns)

RegEx also allows you to match patterns that are only at the beginning of a string. We’ve already talked about ^ creating a negating set. We can use the same symbol to find a match only at the beginning of a string.

RegEx还允许您匹配仅在字符串开头的模式。 我们已经讨论过^创建一个求反集。 我们只能在字符串开头使用相同的符号来查找匹配项。

let calAndRicky = "Cal and Ricky both like racing.";
// Match 'Cal' only if it's at the beginning of a string. let calRegex = /^Cal/;
let result = calRegex.test(calAndRicky); // Returns true
let rickyAndCal = "Ricky and Cal both like racing.";
let result = calRegex.test(rickyAndCal); // Returns false

18.匹配结束字符串模式 (18. Match Ending String Patterns)

What about matching a pattern at the end of a string? We can use $ for that.

匹配字符串末尾的模式呢? 我们可以为此使用$

let caboose = "The last car on a train is the caboose";
// Match 'caboose' if it's at the end of a string.let lastRegex = /caboose$/;
let result = lastRegex.test(caboose); // Returns true

19.匹配所有字母和数字 (19. Match All Letters and Numbers)

Earlier in parts 10 and 11 I showed you how we can match ranges of letters and numbers. If I asked you to write a RegEx that matches all the letters and numbers and ignore their cases you probably would have written something like /[a-z0-9]/gi and that’s exactly right. But it’s a bit too long.

在第10部分和第11部分的前面,我向您展示了如何匹配字母和数字范围。 如果我要求您编写一个与所有字母和数字匹配的RegEx并忽略它们的大小写,您可能会编写类似/[a-z0-9]/gi ,这是完全正确的。 但这太长了。

RegEx has something called ‘Shorthand Character Classes’, which is basically a shorthand for common RegEx expression. For matching all letters and numbers we can use \w and we also get underscore _ matched as a bonus.

RegEx有一个称为“简写字符类”的东西,它基本上是常见RegEx表达式的简写形式。 为了匹配所有字母和数字,我们可以使用\w ,并且还会得到下划线_作为奖励。

let quoteSample = "The five boxing wizards jump quickly.";
// Same as /[a-z0-9_]/gi to match a-z (ignore case), 0-9 and _let alphabetRegexV2 = /\w/g;
// The length of all the characters in a string// excluding spaces and the period. let result = quoteSample.match(alphabetRegexV2).length;
// Returns 31

20.匹配除字母和数字以外的所有内容 (20. Match Everything But Letters and Numbers)

If we want to do the opposite and match everything that is not a letter or a number (also exclude underscore _), we can use \W

如果我们想做相反的事情并且匹配不是字母或数字的所有内容(还排除下划线_ ),则可以使用\W

let quoteSample = "The five boxing wizards jump quickly.";
// Match spaces and the periodlet nonAlphabetRegex = /\W/g;
let result = quoteSample.match(nonAlphabetRegex).length;
// Returns 6

21.匹配所有数字 (21. Match All Numbers)

Ok, what about if you want only numbers? Is there a shorthand character class for that? Sure, it’s \d.

好吧,如果您只想要数字呢? 有速记字符类吗? 当然是\d

let numString = "Your sandwich will be $5.00";
// Match all the numberslet numRegex = /\d/g;
let result = numString.match(numRegex).length; // Returns 3

22.匹配所有非数字 (22. Match All Non-Numbers)

Would you like the opposite and match all the non-numbers? Use \D

您要相反,并匹配所有非数字吗? 使用\D

let numString = "Your sandwich will be $5.00";
// Match everything that is not a numberlet noNumRegex = /\D/g;
let result = numString.match(noNumRegex).length; // Returns 24

23.限制可能的用户名 (23. Restrict Possible Usernames)

So far so good! Well done for making it this far. RegEx can be tricky as it’s not the most easily readable way to code. Let’s now look at a very real-life example and make a username validator. In this case you have 3 requirements:

到目前为止,一切都很好! 到目前为止,做得很好。 RegEx可能很棘手,因为它不是最容易阅读的编码方式。 现在,让我们看一个非常真实的示例,并创建一个用户名验证器。 在这种情况下,您有3个要求:

  • If there are numbers, they must be at the end.

    如果有数字,它们必须在末尾。
  • Letters can be lowercase and uppercase.

    字母可以是小写和大写。
  • At least two characters long. Two-letter names can’t have numbers.

    至少两个字符长。 两个字母的名称不能包含数字。

Try to solve this on your own and if you find it difficult or just want to check the answer, check out my solution.

尝试自己解决此问题,如果发现困难或只是想查看答案, 请查看我的解决方案。

24.匹配空白 (24. Match Whitespace)

Can we match all the whitespaces? Of course, we can use a shorthand for that too and it’s \s

我们可以匹配所有空格吗? 当然,我们也可以使用简写形式,它是\s

let sample = "Whitespace is important in separating words";
// Match all the whitespaceslet countWhiteSpace = /\s/g;
let result = sample.match(countWhiteSpace);
// Returns [" ", " ", " ", " ", " "]

25.匹配非空白字符 (25. Match Non-Whitespace Characters)

Can you guess how to match all non-whitespace characters? Well done, it’s \S!

您能猜出如何匹配所有非空白字符吗? 做得好,它是\S

let sample = "Whitespace is important in separating words";
// Match all non-whitespace characterslet countWhiteSpace = /\S/g;
let result = sample.match(countWhiteSpace);

26.指定匹配的上限和下限 (26. Specify Upper and Lower Number of Matches)

You can specify the lower and upper number of pattern matches with ‘Quantity Specifiers’. They can be used with {} syntax, for example {3,6}, where 3 is the lower bound and 6 is the upper bound to be matched.

您可以使用“数量说明符”指定模式匹配的上下数量 它们可以与{}语法一起使用,例如{3,6} ,其中3是要匹配的下限, 6是要匹配的上限。

let ohStr = "Ohhh no";
// We want to match 'Oh's that have 3-6 'h' characters in it. let ohRegex = /Oh{3,6} no/;
let result = ohRegex.test(ohStr); // Returns true

27.仅指定较低的匹配数 (27. Specify Only the Lower Number of Matches)

When we want to specify only the lower bound, we can do it by omitting the upper bound, for example to match at least three characters we can write {3,}. Notice that we still need a comma, even when we don’t specify the upper limit.

当我们只想指定下限时,可以省略上限,例如匹配至少三个可以写{3,}字符。 请注意,即使我们未指定上限,我们仍然需要逗号。

let haStr = "Hazzzzah";
// Match a pattern that contains at least for 'z' characterslet haRegex = /z{4,}/;
let result = haRegex.test(haStr); // Returns true

28.指定确切的匹配数 (28. Specify Exact Number of Matches)

In the previous section I mentioned that we need a comma in {3,} when we specify only the lower bound. The reason is when you write {3} without a comma, it means that you are looking to match exactly 3 characters.

在上一节中,我提到当仅指定下限时,我们需要在{3,}使用逗号。 原因是当您写{3}没有逗号时,这意味着您要查找的字符正好匹配3个字符。

let timStr = "Timmmmber";
// let timRegex = /Tim{4}ber/;
let result = timRegex.test(timStr); // Returns true

29.检查全部或无 (29. Check for All or None)

There are times when you might want to specify a possible existence of a character in your pattern. When a letter or a number is optional and we would use ? for that.

有时您可能希望在模式中指定字符的可能存在。 当字母或数字是可选的并且我们将使用? 为了那个原因。

// We want to match both British and American English spellings // of the word 'favourite'
let favWord_US = "favorite";let favWord_GB = "favourite";
// We match both 'favorite' and 'favourite' // by specifying that 'u' character is optionallet favRegex = /favou?rite/; // Change this line
let result1 = favRegex.test(favWord_US); // Returns truelet result2 = favRegex.test(favWord_GB); // Returns true

30.正负前瞻 (30. Positive and Negative Lookahead)

Lookaheads’ are patterns that tell your JS to lookahead to check for patterns further along. They are useful when you’re trying to search for multiple patterns in the same strings. There 2 types of lookaheads — positive and negative.

前瞻 ”是告诉您的JS提前检查模式的模式。 当您尝试在同一字符串中搜索多个模式时,它们很有用。 先行有2种类型-正向和负向。

Positive lookahead uses ?= syntax

正向超前使用?=语法

let quit = "qu";
// We match 'q' only if it has 'u' after it. let quRegex= /q(?=u)/;
quit.match(quRegex); // Returns ["q"]

Negative lookahead uses ?! syntax

负向超前使用?! 句法

let noquit = "qt";
// We match 'q' only if there is no 'u' after it. let qRegex = /q(?!u)/;
noquit.match(qRegex); // Returns ["q"]

31.使用捕获组重用模式 (31. Reuse Patterns Using Capture Groups)

Let’s imagine we need to capture a repeating pattern.

假设我们需要捕获一个重复模式。

let repeatStr = "regex regex";
// We want to match letters followed by space and then letterslet repeatRegex = /(\w+)\s(\w+)/;
repeatRegex.test(repeatStr); // Returns true

Instead of repeating (\w+) at the end we can tell RegEx to repeat the pattern, by using \1. So the same as above can be written again as:

不用在结尾重复(\w+) ,我们可以使用\1告诉RegEx重复模式。 因此,与上面相同,可以再次写成:

let repeatStr = "regex regex";
let repeatRegex = /(\w+)\s\1)/;
repeatRegex.test(repeatStr); // Returns true

32.使用捕获组搜索和替换 (32. Use Capture Groups to Search and Replace)

When we find a match, it’s sometimes handy to replaced it with something else. We can use replace() method for that.

当我们找到一个匹配项时,有时用其他替换项很方便。 我们可以使用replace()方法。

let wrongText = "The sky is silver.";
let silverRegex = /silver/;
wrongText.replace(silverRegex, "blue");
// Returns "The sky is blue."

33.从开始和结束中删除空格 (33. Remove Whitespace from Start and End)

Here’s a little challenge for you. Write a RegEx that would remove any whitespace around the string.

这对您来说是一个小挑战。 编写一个RegEx,它将删除字符串周围的所有空格。

let hello = "   Hello, World!  ";
let wsRegex = /change/; // Change this line
let result = hello; // Change this line

If you get stuck or just want to check my solution, feel free to have a look at the Scrimba cast where I solve this challenge.

如果您遇到困难或只是想检查我的解决方案,请随时查看我解决此挑战的Scrimba演员表 。

34.结论 (34. Conclusion)

Congratulations! You have finished this course! If you’d like to keep learning more, feel free to checkout this YouTube playlist, that has a lot of JavaScript projects you can create.

恭喜你! 您已完成本课程! 如果您想继续学习,请随时查看此YouTube播放列表 ,其中可以创建许多JavaScript项目。

Keep learning and thanks for reading!

继续学习,并感谢您的阅读!

You are now ready to play regex golf. ?

现在,您可以开始玩正则表达式高尔夫了。 ?

翻译自: https://www.freecodecamp.org/news/learn-regular-expressions-with-this-free-course-37511963d278/

java正则表达式课程

相关文章:

Codeforces Round #370 (Div. 2)

A - Memory and Crow 这题我没看题意&#xff0c;看了样例猜了一下就AC了&#xff0c;题目好像还挺复杂的。 #include<bits/stdc.h> using namespace std; int a[100005]; int main() {int n;cin>>n;for(int i1;i<n;i) scanf("%d",&a[i]);for(int…

pat1004. Counting Leaves (30)

1004. Counting Leaves (30) 时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contains…

css 引用字体

最近遇到个问题&#xff0c;页面使用的字体要用PingFangSC字体&#xff0c;引入方法如下&#xff1a; 简单介绍下PingFangSC字体&#xff1a; &#xff08;1&#xff09;苹方-简 常规体 font-family: PingFangSC-Regular, sans-serif; &#xff08;2&#xff09;苹方…

系统技术方案 系统构架_构架系统时应注意的事项

系统技术方案 系统构架by Ayelet Sachto通过Ayelet Sachto 架构系统时要记住的6件事 (6 Things to keep in mind when architecting a system) Architecture may sound like a “scary ” or overwhelming subject, but actually, applying logic and approaching the problem…

[LeetCode] Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num 38, the process is like: 3 8 11, 1 1 2. Since 2 has only one digit, return it. 分析一&#xff1a;最简单的循环方法 class Solutio…

vue 点击事件执行多次

把 click 改成 click.once 就可以了 示例代码 click.once"down" 这样有一个弊端&#xff0c;就是事件只执行一次就不再执行了&#xff0c; 另一种方式&#xff0c;做一个定时器 //默认设置dddown为 true if(that.dddown){that.dddown falsesetTimeout(function(…

如何以及为什么使用Android Visibility Listeners

The Android UI is built up from Views, and in a regular application, there are usually several of them. To find out which View the user is currently looking at, you need to install Visibility Listeners.Android UI是从Views构建的&#xff0c;在常规应用程序中&…

在vue中使用Element-UI

Element-UI是一套基于Vue2.0的UI组件库&#xff0c;http://element.eleme.io/#/zh-CN/component/carousel 首先npm install element-ui --save 然后在main.js中引入&#xff1a; import Vue from vue import ElementUI from element-ui import element-ui/lib/theme-default/in…

Flex布局教程(来源:阮一峰)

网页布局&#xff08;layout&#xff09;是 CSS 的一个重点应用。Flex 布局将成为未来布局的首选方案。本文介绍它的语法&#xff0c;下一篇文章给出常见布局的 Flex 写法。网友 JailBreak 为本文的所有示例制作了 Demo&#xff0c;也可以参考。 以下内容主要参考了下面两篇文…

ibatis的there is no statement named xxx in this SqlMap

报错情况如下&#xff1a;com.ibatis.sqlmap.client.SqlMapException: There is no statement named Control.insert-control in this SqlMap. at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:231)at com.ibatis.sq…

javascript案例_如何在JavaScript中使用增强现实-一个案例研究

javascript案例by Apurav Chauhan通过Apurav Chauhan 如何在JavaScript中使用增强现实-一个案例研究 (How to use Augmented Reality with JavaScript — a case study) In this experiment, I talk about how Augmented Reality with JS can be used to make learning more f…

久未更 ~ 一之 —— 关于ToolBar

很久没更博客了&#xff0c;索性开一个久未更 系列 > > > > > 久未更 系列一&#xff1a;关于ToolBar的使用(后续补充) 1 //让 ToolBar 单独使用深色主题 使得 toolbar 中元素 变为淡色 2 android:theme"style/ThemeOverlay.AppCompat.Dark.ActionBar"…

SQLServer怎样把本地数据导入到远程服务器上(转载)

平常用到mssql时间比较少&#xff0c;总是过一段时间就忘记应该怎么操作了。当要做mssq把本地数据导入到远程服务器的时候&#xff0c;就去网上搜索很久都没有图解的&#xff0c;所以今天自己收集一下免得下次又到处去找。希望对自己&#xff0c;同时对其它需要的人都有一定的帮…

input 默认样式的修改

/* 修改input选中的默认边框样式 */ outline: none; /* 修改input的选中时的光标颜色 */ caret-color:red; /* 修改input的选中时的默认边框 */ border: none; /* 修改input的提示文字的默认样式 */ input::-webkit-input-placeholder{color:#d0d0d0;}

巨石加密_点餐:如何吃一个可怕的巨石

巨石加密by Alan Ridlehoover通过艾伦里德尔霍弗 点餐&#xff1a;如何吃一个可怕的巨石 (Ordering Take Out: How to Eat a Scary Monolith) Martin Fowler said:马丁福勒(Martin Fowler) 说 &#xff1a; Almost all the successful microservice stories have started wit…

Halcon学习之六:获取Image图像中Region区域的特征参数

area_center_gray ( Regions, Image : : : Area, Row, Column ) 计算Image图像中Region区域的面积Area和重心&#xff08;Row&#xff0c;Column&#xff09;。 cooc_feature_image ( Regions, Image : : LdGray, Direction : Energy,Correlation, Homogeneity, Contrast ) …

dos下命令行执行程序时候注意程序所使用文件的路径问题

dos下命令行执行程序时候&#xff0c;最好是用cd命令先切换到程序所在目录下&#xff0c;这样就不会出现文件找不到的问题&#xff0c;如果由于特殊原因&#xff0c;不使用cd命令&#xff0c;而只使用路径命令时候程序中访问的资源也只能是改成绝对路径了&#xff0c;这样对有源…

Vant 使用之Toast Vant安装和使用

Vant 是一个VUE 的移动端组件库&#xff0c;里面有很多好用的组件。 第一步&#xff0c;安装和配置 Vant npm i vant -S npm i babel-plugin-import -D 安装完成之后&#xff0c;在项目 .babelrc 文件修改配置 plugins "plugins": [["import", {"…

15-5重构_重构-糟糕,我一直在向后做。

15-5重构by Justin Fuller贾斯汀富勒(Justin Fuller) 重构-糟糕&#xff0c;我一直在向后做。 (Refactoring — oops, I’ve been doing it backwards.) Welcome to my intervention. I’m a refactoring addict and I’m not afraid to admit it, but there’s only one prob…

JPush 使用教程

JPush 使用教程 自己使用的一些经验&#xff0c;为了方便直接从这里复制过去就行。 就当做个笔记&#xff0c;防止长时间忘记之后&#xff0c;还需要去官网看文档。 主要思路&#xff1a; sdk文件 三方依赖系统库 头文件 添加代理 初始化代码 1.版本信息 JPush : 2.2.0 Xco…

浏览器常见兼容性问题汇总

1、随便写几个标签&#xff0c;不加样式控制的情况下&#xff0c;各自的margin 和padding差异较大&#xff0c;解决方案是&#xff1a;*{margin:0;padding:0;} 2、块属性标签float后&#xff0c;又有横行的margin情况下&#xff0c;在IE6显示margin比设置的大&#xff0c;常出现…

VUE 动态绑定class

第一种&#xff1a;通过一个布尔值判断样式类是否生效 //isActive 是在data里面布尔值&#xff0c; rotateRight 是 class 样式类 //isActive 为true时样式类 rotateRight 生效 <div :class"{rotateRight:isActive}">abs</div> 第二种&#xff1a;通…

低声教育_我内心低声说:“成为建设者”

低声教育by Rebecca Radding由丽贝卡拉丁(Rebecca Radding) 我内心低声说&#xff1a;“成为建设者” (Something within me whispered: “Be the builder”) 加沙代码学院前任主持人Yasmin Hillis(自称嬉皮士)是一个内心的嬉皮士&#xff0c;她谈到了弗吉尼亚伍尔夫如何激发她…

【Web API系列教程】1.2 — Web API 2中的Action Results

前言 本节的主题是ASP.NET Web API怎样将控制器动作的返回值转换成HTTP的响应消息。 Web API控制器动作能够返回下列的不论什么值&#xff1a; 1。 void 2。 HttpResponseMessage 3&#xff0c; IHttpActionResult 4&#xff0c; Some other type 取决于返回的以上哪一种。…

前端开发常用单词

methods 方法 mounted 创建完成 export 输出 default 默认的 install 安装 components 组件 template 模板 params 参数 route 路线;途径 package 包;盒子;袋 ; toutes 路由器 plugin 插件 local host 本地 require 需要;依赖; storage 储存 prototype 原型 …

原生ajax的post操作

xml.open(方法&#xff0c;路径&#xff0c;是否开启异步)&#xff1b; console.log(e);来找出数据所在位置&#xff1b; 调用 ajax只能传二进制或字符串&#xff0c;需要先把json转一下&#xff0c;JSON.stringify()&#xff1b; 获取到数据时我们要通过JSON.parse()再转成JSO…

jquery后学什么_我在训练营两年后学到了什么

jquery后学什么by Kara Luton卡拉卢顿(Kara Luton) 我在训练营两年后学到了什么 (What I’ve Learned Two Years Post-Bootcamp) It’s been two entire years since I left behind my career of being a music publicist — one I worked towards all of college and miracul…

ExecutorService 的理解与使用

接口 Java.util.concurrent.ExecutorService 表述了异步执行的机制&#xff0c;并且可以让任务在后台执行。壹個 ExecutorService 实例因此特别像壹個线程池。事实上&#xff0c;在 java.util.concurrent 包中的 ExecutorService 的实现就是壹個线程池的实现。 ExecutorService…

前后端交互,网络请求

这边文章主要根据我自己的前端开发工作经验&#xff0c;东拼西凑出来的一点理解&#xff0c;希望能够对大家有点帮助&#xff0c;如果有误导或者错误的地方还请帮助指正&#xff0c;感谢&#xff01;&#xff01;&#xff01; 前后端交互我理解主要分为三个主要的部分&#xf…

HDU 1877 另一个版本 A+B

另一个版本 AB Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12894 Accepted Submission(s): 4901Problem Description输入两个不超过整型定义的非负10进制整数A和B(<231-1)。输出AB的m (1 < m <10…