首页 \ 问答 \ 在文件中搜索关键字并在Clojure中找到它的值(Search keyword in a file and find it's value in Clojure)

在文件中搜索关键字并在Clojure中找到它的值(Search keyword in a file and find it's value in Clojure)

我有一个文件“test.txt”,内容如下:

TAG A    : HELLO 
DATE START   : Tue Oct 25 09:51:49 EDT 2015 
GIT BRANCH   : master 
GIT COMMIT   : fecb1b53ec8fffffffffffffffffffff09523c42 

我必须从这个文件中找到“GIT BRANCH”的值,它应该是“master”。

我实现这一目标的逻辑是逐行读取此文件,匹配关键字“GIT BRANCH”并找出它的值。 我能够逐行读取文件并匹配关键字,但我不知道如何获得它的价值。

我是Clojure的新手,任何帮助实现这一目标将不胜感激。

谢谢。


I have a file "test.txt" with following contents:

TAG A    : HELLO 
DATE START   : Tue Oct 25 09:51:49 EDT 2015 
GIT BRANCH   : master 
GIT COMMIT   : fecb1b53ec8fffffffffffffffffffff09523c42 

I have to find the value of "GIT BRANCH" from this file, which should be "master".

My logic to achieve this was to read this file line by line, match the keyword "GIT BRANCH" and find out it's value. I was able to read the file line by line and match the keyword but I don't know how to get it's value.

I am new to Clojure, any help to achieve this would be greatly appreciated.

Thanks.


原文:https://stackoverflow.com/questions/40352381
更新时间:2022-12-20 09:12

最满意答案

这通常会使组件成组时更容易移动/处理。

在某种程度上,它更符合逻辑,与物理世界相似。

让我们说大胆的单词是容器,斜体是组件(粗体斜体单词是......容器和组件)。 现在,如果你试图描述一个书架 :它在一个房子里 ,一个房间里一边 ,它有多个架子,每个架子里都有一些东西 。 并且每个通常相对于其容器放置。

如果你想找一本书,它就在书架上。 如果要移动书架,则包含的每个组件将同时移动。 听起来很明显,对吧?

当然,可以使用更少的容器。 我们看到一个房间里 。 它们与以前处于同一位置,但我们认为它们不再位于书架容器中。

房间里还有书。 他们仍然在同一个地方,他们仍然表现得像书。

如果,当你试图移动书架时,书籍和东西会悬浮在他们旧位置的空中吗? 好吧,如果您不使用这些容器,那可能会发生什么。


That usually make it easier to move/process as your components are in groups.

And in some way, it's more logical and similar to the physical world.

Let's say bold words are containers and italics are components (and bold italic word are... containers and component). Now if you try to describe a bookshelf: it' in a house, in a room, on a side, it has multiple shelves and each shelf contains some books or stuff. And each one is normally put relatively to its container.

If you wan to locate a book, it's in the bookshelf. If you want to move the bookshelf, each components contained will be moved simultaneously. That sounds pretty obvious, right?

Of course, it's possible to use less containers. We saw a room contains books. They are in the same spot as before but we decide they are not in the bookshelf container any more.

The room still contains books. They still are at the same location and they still behave like books.

Will it sound right if, when you attempt to move the bookshelf, books and stuff stay floating in the air at their old location? Well, that's probably what would happen if you don't use those containers.

相关问答

更多
  • linux怎样进入GUI[2023-09-20]

    你使用redlinux(红旗Linux)等就是Gui界面,现在有很多GUI方式的Linux系统的。
  • 在我看来,容器的价值(如容器理论)就是它们的一致性 。 这种一致性使得使用容器表示作为可执行规范的基础,甚至可能使用机器辅助的程序派生。 容器:理论工具,而不是一个很好的运行时数据表示策略 我不会推荐(标准化)容器的固定点作为实现递归数据结构的一种很好的通用方法。 也就是说,知道给定的函子具有(最多为iso)作为容器的演示文件是有帮助的,因为它告诉您可以实例化通用容器功能(这很容易实现,一次完成,归功于均匀性)可以实例化到你特定的仿函数,以及你应该期望的行为。 但这并不是说容器实现将以任何实际的方式高效。 ...
  • 我可以想象,微软选择Int32是因为UInt32不符合CLS(换句话说,并非所有使用.NET框架的语言都支持无符号整数)。 I would imagine that Microsoft chose Int32 because UInt32 is not CLS-compliant (in other words not all languages that use the .NET framework support unsigned integers).
  • 如果项目的构建过程不仅仅涉及编译源代码 ,那么构建工具(如NAnt)将允许您自定义和扩展该过程以执行任何操作。 构建过程的一个示例可以是: 对源代码运行静态分析 编 运行所有单元测试 创建部署包 将部署包发布到网络位置 单独使用Visual Studio UI自动执行此类过程可能非常具有挑战性。 我应该指出, Visual Studio本身在内部使用构建工具来完成名为MSBuild的工作。 MSBuild 在架构上与 NAnt 非常相似 ,并且具有直接构建在.NET Framework中的优势。 MSBui ...
  • 页面的某些部分将覆盖完整的视口宽度,而其他部分将不会。 一些背景将是全宽,但内容不会。 一个例子是一个特征区域,它具有背景图像或颜色,它是视口的整个宽度,但其内部的内容,形式或任何内容不会超过任何给定视口宽度的.container 。 你不会嵌套.container或.container-fluid - 请参阅文档 。 这不是必需的。 文件:Bootstrap需要一个包含元素来包装网站内容并放置我们的网格系统。 您可以选择在项目中使用的两个容器之一。 请注意,由于填充和更多,两个容器都不可嵌套[也不意味着. ...
  • 我建议使用MigLayout 。 它是一个非常强大且非常受支持的第三方布局管理器。 已经(迄今为止不成功)请愿将其包含在Java中。 MigLayout将允许您做任何您想做的事情,而不必做出任何妥协,并使用更少的代码。 我可以继续谈论它,但如果你只是浏览他们的演示和示例代码,你会亲眼看到。 I recommend using MigLayout. It is a very powerful and very well supported 3rd party layout manager. There hav ...
  • 我也很喜欢Kitematic! 作为CoreOS的替代品,您可以尝试docker-ui ,并且它是evolution portainer 。 他们都是码头集装箱,可以帮助您查找/运行码头图像并检查码头工人数量/网络/集装箱统计数据。 您也可以直接通过Web UI启动新的容器。 更多关于这个Portainer可能性的好评的信息 Rancher Labs的Rancher UI也许值得一看。 它更多地被设计成码头工具编排工具(例如,当您操作码头群集群时)。 I also like Kitematic a lot! ...
  • 这通常会使组件成组时更容易移动/处理。 在某种程度上,它更符合逻辑,与物理世界相似。 让我们说大胆的单词是容器,斜体是组件(粗体斜体单词是......容器和组件)。 现在,如果你试图描述一个书架 :它在一个房子里 ,一个房间里 , 一边 ,它有多个架子,每个架子里都有一些书或东西 。 并且每个通常相对于其容器放置。 如果你想找一本书,它就在书架上。 如果要移动书架,则包含的每个组件将同时移动。 听起来很明显,对吧? 当然,可以使用更少的容器。 我们看到一个房间里有书 。 它们与以前处于同一位置,但我们认为它 ...
  • 您可以像在此示例中那样执行此操作 function doGet() { var app = UiApp.createApplication() var Panel = app.createAbsolutePanel().setStyleAttribute('background', 'beige').setPixelSize(400,600); var label = app.createLabel('gui test') var gui = app.loadComponent('MyGui ...
  • 每个QGraphicItem实际上都是一个容器,因为每个项都可以选择为QGraphicsItem父级。 当你这样做时,父母会影响它的所有孩子......如果父母被移动,孩子会随之移动。 如果在父级上设置了变换,可见性或不透明度,则这些更改也适用于子级。 基本上,你的理解是正确的; 你会创建一个绘制容器轮廓的父QGraphicsItem ,然后你会有孩子,每个孩子都画出他们的图标或任何合适的图标。 或者,您可以在QGraphicsScene使用窗口小部件,因此所有基于窗口小部件的容器都可用。 如果这是您想要的 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。