Skip to content

Commit

Permalink
README: added findstring function section.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno-Jesus committed Jul 31, 2023
1 parent f8c9602 commit e9f8a5e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ It starts with a beginner's guide, followed up by some medium-advanced concepts.
<ul style="list-style-type:disc">
<li><a href="#functions-1">A4.1 - Functions Call Syntax</a></li>
<li><a href="#functions-2">A4.2 - Functions for String Manipulation</a></li>
<li><a href="#functions-3">A4.3 - Functions for File Names</a></li>
<li><a href="#functions-4">A4.4 - Functions for Generic Purpose</</li>a>
</ul>
<!-- <li><a href="#vpath">The vpath directive</a></li> -->
</ul>
Expand Down Expand Up @@ -1088,7 +1090,7 @@ BAR=a,b,c

### <a name="functions-2">A4.2 - Functions for String Manipulation</a>

<details open>
<details>
<summary><h4>patsubst</h4> - replaces string patterns</summary>

```
Expand Down Expand Up @@ -1165,11 +1167,38 @@ RESULT == a b c
```
</details>

<details>
<summary><h4>findstring</h4> - looks for occurrences of a string</summary>

```
$(findstring find,in)
```

If the text `in` contains a word identical to `find`, the function returns `find`. Otherwise, it returns the empty string.

Here's an example ([code/18-findstring-example](code/18-findstring-example)):

```Makefile
NAME = Nuno Jesus

all:
echo Result=$(findstring Jesus, $(NAME))
echo Result=$(findstring Miguel, $(NAME))
.SILENT:
```

Output:

```
Result=Jesus
Result=
```
</details>
<!--
Functions for strings manipulation
$(findstring find,in)
$(filter pattern…,text)
$(words text)
Expand Down Expand Up @@ -1547,6 +1576,15 @@ Self-explanatory, you forgot to add an `endif` directive to your conditional.

------------------------------------------------------------------

### <a name="functions-3">A4.3 - Functions for File Names</a>


------------------------------------------------------------------

### <a name="functions-4">A4.4 - Functions for Generic Purpose</a>


------------------------------------------------------------------

## 📞 **Contact me**
Feel free to ask me any questions through Slack (**ncarvalh**).
Expand Down
6 changes: 6 additions & 0 deletions code/18-findstring-example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NAME = Nuno Jesus

all:
echo Result=$(findstring Jesus, $(NAME))
echo Result=$(findstring Miguel, $(NAME))
.SILENT:

0 comments on commit e9f8a5e

Please sign in to comment.