Regular Expression Basics Word Boundaries

Screen Link:

My Code:

def first_10_matches(pattern3):
    all_matches = titles[titles.str.contains(pattern3)]
    first_10 = all_matches
    return first_10
java_titles = first_10_matches(r"\b[J]ava\b")

What I expected to happen:

title
436	Unikernel Power Comes to Java, Node.js, Go, and Python Apps
811	Ask HN: Are there any projects or compilers which convert JavaScript to Java?
1023	Pippo  Web framework in Java
1972	Node.js vs. Java: Which Is Faster for APIs?
2093	Java EE and Microservices in 2016
2367	Code that is valid in both PHP and Java, and produces the same output in both
2493	Ask HN: I've been a java dev for a couple of years, should I move langauge?
2751	Eventsourcing for Java 0.4.0 released
3228	Comparing Rust and Java
3452	What are the Differences Between Java Platforms from Desktops to Wearables?
3627	Friends don't let friends do Java
4273	Ask HN: Is Bloch's Effective Java Still Current?
4624	Oracle Discloses Critical Java Vulnerability in 7u97, 8u73, and 8u74
5461	Lambdas (in Java 8) Screencast
5847	IntelliJ IDEA and the whole IntelliJ platform migrates to Java 8
6268	Oracle deprecating Java applets in Java 9
7436	Forget Guava: 5 Google Libraries Java Developers Should Know
7481	Ask HN: Beside Java what languages have a strong tooling/IDE ecosystem on Linux?
7686	Insider: Oracle has lost interest in Java
8100	Advantages of Functional Programming in Java 8
8447	Show HN: Java multicore intelligence
8487	Why IntelliJ IDEA is hailed as the most friendly Java IDE (many screenshots)
8984	Ask HN: Should Learn/switch to JavaScript Programming (a Java Developer)
8987	Last-khajiit/vkb: Java bot for vk.com competitions
10529	Angular 2 coming to Java, Python and PHP
11454	Ask HN: Java or .NET for a new big enterprise system?
11902	The Java Deserialization Bug
12382	Ask HN: Why does Java continue to dominate?
12582	Java Memory Model Examples: Good, Bad and Ugly (2007) [pdf]
12711	Oracle seeks $9.3B for Googles use of Java in Android
12730	Show HN: Shazam in Java
13048	A high performance caching library for Java 8
13105	Show HN: Backblaze-b2 is a simple java library for Backblaze B2
13150	Java Tops TIOBE's Popular-Languages List
13170	Show HN: Tablesaw: A Java data-frame for 500M-row tables
13272	Java StringBuffer and StringBuilder performance
13620	1M Java questions have now been asked on StackOverflow
13839	Ask HN: Hosting a Java Spring web application
13843	Var and val in Java?
13844	Answerz.com  Java and J2ee Programming
13930	Java 8s new Optional type doesn't solve anything
13934	Java 6 vs. Java 7 vs. Java 8 between 2013  2016 usage stats
14393	JavaScript is immature compared to Java
14847	Show HN: TurboRLE: Bringing Turbo Run Length Encoding Incl. SIMD to Java
15257	Oracle and the fall of Java EE
15868	Java generics never cease to impress
16023	Will you use ReactJS with a REST service instead of GWT in Java app?
16932	Swift versus Java: the bitset performance test
16948	Show HN: Bt  0-hassle BitTorrent for Java 8
17458	Super Mario clone in Java
17579	Java Lazy Streamed Zip Implementation
18407	Show HN: Scala idioms in Java: cases, patterns, for-comp, implicits ++
19481	Show HN: Adding List Comprehension in Java - ExprEngine
19735	Java Named Top Programming Language of 2015

What actually happened:

title
436	Unikernel Power Comes to Java, Node.js, Go, and Python Apps
811	Ask HN: Are there any projects or compilers which convert JavaScript to Java?
1023	Pippo  Web framework in Java
1972	Node.js vs. Java: Which Is Faster for APIs?
2093	Java EE and Microservices in 2016
2367	Code that is valid in both PHP and Java, and produces the same output in both
2751	Eventsourcing for Java 0.4.0 released
3228	Comparing Rust and Java
3452	What are the Differences Between Java Platforms from Desktops to Wearables?
3627	Friends don't let friends do Java
4273	Ask HN: Is Bloch's Effective Java Still Current?
4624	Oracle Discloses Critical Java Vulnerability in 7u97, 8u73, and 8u74
5461	Lambdas (in Java 8) Screencast
5847	IntelliJ IDEA and the whole IntelliJ platform migrates to Java 8
6268	Oracle deprecating Java applets in Java 9
7436	Forget Guava: 5 Google Libraries Java Developers Should Know
7481	Ask HN: Beside Java what languages have a strong tooling/IDE ecosystem on Linux?
7686	Insider: Oracle has lost interest in Java
8100	Advantages of Functional Programming in Java 8
8447	Show HN: Java multicore intelligence
8487	Why IntelliJ IDEA is hailed as the most friendly Java IDE (many screenshots)
8984	Ask HN: Should Learn/switch to JavaScript Programming (a Java Developer)
8987	Last-khajiit/vkb: Java bot for vk.com competitions
10529	Angular 2 coming to Java, Python and PHP
11454	Ask HN: Java or .NET for a new big enterprise system?
11902	The Java Deserialization Bug
12382	Ask HN: Why does Java continue to dominate?
12582	Java Memory Model Examples: Good, Bad and Ugly (2007) [pdf]
12711	Oracle seeks $9.3B for Googles use of Java in Android
12730	Show HN: Shazam in Java
13048	A high performance caching library for Java 8
13150	Java Tops TIOBE's Popular-Languages List
13170	Show HN: Tablesaw: A Java data-frame for 500M-row tables
13272	Java StringBuffer and StringBuilder performance
13620	1M Java questions have now been asked on StackOverflow
13839	Ask HN: Hosting a Java Spring web application
13843	Var and val in Java?
13844	Answerz.com  Java and J2ee Programming
13930	Java 8s new Optional type doesn't solve anything
13934	Java 6 vs. Java 7 vs. Java 8 between 2013  2016 usage stats
14393	JavaScript is immature compared to Java
14847	Show HN: TurboRLE: Bringing Turbo Run Length Encoding Incl. SIMD to Java
15257	Oracle and the fall of Java EE
15868	Java generics never cease to impress
16023	Will you use ReactJS with a REST service instead of GWT in Java app?
16932	Swift versus Java: the bitset performance test
16948	Show HN: Bt  0-hassle BitTorrent for Java 8
17458	Super Mario clone in Java
17579	Java Lazy Streamed Zip Implementation
18407	Show HN: Scala idioms in Java: cases, patterns, for-comp, implicits ++
19481	Show HN: Adding List Comprehension in Java - ExprEngine
19735	Java Named Top Programming Language of 2015```

<!--Enter other details below: -->
My code was able to run, but the issue is that my answer is too short. Should I be using two parameters in the function, or should I be using the re.search method somewhere? I feel like my pattern is correct
Thank you
-Salem

Hi @salemabdulkerim ,

I probably missed something but I was reading your question and I was trying to understand what is the problem you are experiencing?

1 Like

My answer is too short. There are some titles in my answer that are not appearing
-Salem

The first screenshot I sent is the output I got and the second screenshot I sent is the correct answer
-Salem

Hint:

2 Likes

Yeah. I thought I did that when I had first_10_matches(r"\bJava\b").

1 Like

I figured it out. Thanks!
-Salem

1 Like

Also, with re.search(), what is ```re``? Is that suppose to be some kind of function?

1 Like

re is the Python module for Regular Expression, search() is a function in the re module. For more details refer this.

3 Likes

Sounds good. Thanks!
-Salem