杰森图正则表达式断言可以识别定义在Java1.8Pattern类的句法。Pattern类的文档在
 https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html. 
Java正则表达式句法可以不同于您以前使用的,所以需要花一些时间来学习这个URL的文档。下面的查询使用了textContainsRegex断言来找到城市名中以for开头的,忽略大小写。
The JanusGraph regular expression predicates recognize the syntax defined as part of the Java 1.8
Pattern class that is documented at https://docs.oracle.com/javase/8/docs/api/java/util/regex/
Pattern.html. The Java regular expression syntax may be different than the one you are used to so it
is worth taking a few minutes to study the documentation at that URL.
The query below uses a textContainsRegex predicate to search for any city name that contains a
word starting with for, while ignoring case.
注意名称以For开头,例如 Fort Myers和城市名包含以 For开头的单词的都可以找到。例如
La Fortuna 和 View Fort也可以找出来
 
Notice how names that start with For such as Fort Myers as well as city names containing words
that start with the text For in a subsequent word are found. For example La Fortuna and View Fort
are also found.

 

 

 下面的查询说明了另一种找到单词以dallas开头的字符串文本,忽略大小写。这次我们使用了一个简单的正则表达式。当然,事实上,这会和我们使用textContainsPrefix一样,得到相同的结果。

The query below shows another way of searching for the word dallas at the start of a string of text
while ignoring case. This time we use a very simple regular expression. Of course, in reality, this
yields the same result that we could achieve by simply using textContainsPrefix. 
 

如我们所见,查询的处理和我们期待的一样。 

As we can see the query worked as expected. 

 如果我们想对查询进行一点扩展。我们可以修改正则表达式,如下所示。找到城市名以字符串dal开始的。

If we wanted to expand our search a bit we could modify the regular expression, as shown below,
to find an city name that starts with the characters dal.

 这次我们得到了一些额外的城市。

This time we get some additional cities back.

如果我们想要得到更特定的一些, 我们可以再次调整正则表达式。这次我们查找城市名,以任意三个字母开头,后边跟着字符cah ,接着又是任意数量的其它字符。

If we instead wanted to get more specific we could again adjust the regular expression. This time 
we look for any city name that starts with any three characters followed by the characters cah
followed by any number of other characters. 

 使用我们修改的,更加特定的搜索样式,我们只找到了一个与样式匹配的城市名。

Using our modified, and much more specific search pattern we find just one city that matches the
pattern.

 这是另一个例子查找城市名,以任意三个字母开始,后边或跟着cah,或跟着anz,后边又是任意个字母。

Here is another example that looks for a city name that starts with any three characters followed by
either cah or anz followed by any number of characters. 

 这是我们使用正则表达式得到的结果。

Here is what we get back using this regular expression.

 这是另一个查询,使用正则表达式找到机场,它有一个region地区代码以字母US-开始,后边可以是O,R,D三字母之一,再后边又是一些字母。

Here is another query that uses a regular expression to find airports that have a region code that
starts with the characters US- followed by any of O, R or D followed by any number of characters.

 这是查询返回的结果。

Here is what this query returns. 

 这是一个稍复杂一点的使用正则表达式的查询。这个样式匹配任意机场它的描述包含一个单词,这个单词以任意字母开始,后边跟着al,接着可以跟着或没有l,接着是除s,k,e,i之外的任意字母,不考虑大小写。

Here is a slightly more complicated query that uses a regular expression. The pattern matches any
airport description containing a word that starts with any character followed by al, optionally
followed by another l and then followed by any character that is not one of "s,k,e,i" ignoring case.

 这是查询返回的机场描述信息的列表。

Here is the list of airport descriptions that the query returns. 

 

 

posted on 2022-05-04 10:10  bokeyuannicheng0000  阅读(74)  评论(0)    收藏  举报